Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Adding a blank.. item to dropdown?
Vaz
New
Hi guys,
I'd like to add a blank dropdown item to the dropdown menu that appears when you start a new discussion
If you notice currently there's many categories. Sometimes users when they have alot of things on there mind forget to select the correct category.
I wanted to add a blank item so that there posting fails and they go back and correct it by selecting the correct one. How do I add this blank item to the top of the dropdown menu.
I'd like the label to be a line like: ----------------------------------------------
Thanks in advance.
I'd like to add a blank dropdown item to the dropdown menu that appears when you start a new discussion
If you notice currently there's many categories. Sometimes users when they have alot of things on there mind forget to select the correct category.
I wanted to add a blank item so that there posting fails and they go back and correct it by selecting the correct one. How do I add this blank item to the top of the dropdown menu.
I'd like the label to be a line like: ----------------------------------------------
Thanks in advance.
0
This discussion has been closed.
Comments
You actually need to go a bit further down than line 208 since the core file gotten bigger since I posted that. Also, use an IF statement like suggested a few posts later. Maybe I will get around to extensionizing this eventually.
Little more discussion of this technique here.
Currently:-
Not Found
The requested URL /forums/discussion/hello/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
comes up.
(anybody should realise by now that something went wrong on the previous page but just for those slow learners..)
Also in the below code, what purpose does the if statement serve?
For those reading this solution is:
Add the following : -
if (ForceIncomingString('CategoryID', '') == '') {
$cs->AddOption('', 'Please select a category:');
}
in /Library/Vanilla/Vanilla.Control.DiscussionForm.php, just below line 208 (inside GetDiscussionForm, just before the while loop):
You shouldn't be getting a 404 or such... it should be a message that says that you must select a valid category, with all input preserved... exactly the same as if you left the topic or body blank.
Instead of line 208, it should be at or about 210... before the while, but after the $cs = $this->Context->ObjectFactory->NewObject($this->Context, 'Select');
function GetDiscussionForm($Discussion) {
$this->DelegateParameters['Discussion'] = &$Discussion;
$this->CallDelegate('DiscussionForm_PreRender');
if (!$this->DiscussionFormattedForDisplay) $Discussion->FormatPropertiesForDisplay();
$Discussion->Comment->FormatPropertiesForDisplay(1);
// Load the category selector
$cm = $this->Context->ObjectFactory->NewContextObject($this->Context, 'CategoryManager');
$CategoryData = $cm->GetCategories(0, 1);
$cs = $this->Context->ObjectFactory->NewObject($this->Context, 'Select');
$cs->Name = 'CategoryID';
$cs->CssClass = 'CategorySelect';
$cs->SelectedValue = ForceIncomingInt('CategoryID', $Discussion->CategoryID);
$cat = $this->Context->ObjectFactory->NewObject($this->Context, 'Category');
$LastBlocked = -1;
if (ForceIncomingString('CategoryID', '') == '') {
$cs->AddOption('', 'Please select a category:');
}
while ($Row = $this->Context->Database->GetRow($CategoryData)) {
$cat->Clear();
$cat->GetPropertiesFromDataSet($Row);
if ($cat->Blocked != $LastBlocked && $LastBlocked != -1) {
$cs->AddOption("-1", "---", " disabled=\"true\"");
}
$cs->AddOption($cat->CategoryID, $cat->Name);
$LastBlocked = $cat->Blocked;
}
hmm... never tested with Friendly URLs, but don't see how that could be a problem... will have to try it out sometime.
Maybe after I finish this vBulletin migrator thingy ;-)