Search Tools - setting default option
Permalink
I've already messaged the Search Tool developer but not heard back yet. Has anyone used the optional parameter in the controller renderAttributeForm() to pass a custom default option?
I think my lack of php multi-dimension arrays knowledge is really the only issue. I'd appreciate help.
The function I am calling is -
And I want to pass a new defaultValue in using -
However I never get the required default value. I tried swapping the two values in the 2nd dimension. Am I creating the array incorrectly?
Many thanks.
Steve.
I think my lack of php multi-dimension arrays knowledge is really the only issue. I'd appreciate help.
The function I am calling is -
public function renderAttributeForm($akID,$extras=array()) { $form = Loader::helper('form'); if (!is_numeric($akID)) { switch ($akID) { case 'SEARCH_TOOLS_RADIUS_SEARCH': echo $form->text('zip'); $radius = array(); $radius[3] = '3 '.$this->radiusUnits; $radius[10] = '10 '.$this->radiusUnits; $radius[75] = '75 '.$this->radiusUnits; $radius[100] = '100 '.$this->radiusUnits; echo $form->select('radius',$radius,$this->radiusDefault); echo '<input type="hidden" name="radiusUnits" value="'.$this->radiusUnits.'" />'; echo '<input type="hidden" name="radiusAKID" value="'.$this->radiusAKID.'" />'; break;
Viewing 15 lines of 42 lines. View entire code block.
And I want to pass a new defaultValue in using -
However I never get the required default value. I tried swapping the two values in the 2nd dimension. Am I creating the array incorrectly?
Many thanks.
Steve.
Hi Steve, sorry you caught me in the weekend. Thank you for your post above. I will have a look and update my code. Does this answer your other query as well?
Odd, I wrote that code some time ago and now I wonder if I put that on porpoise to get around some hidden c5 bug, or I was playing with it while debugging and left it there by mistake. Anyway, now it makes sense to comment it out, and hopefully it won't be breaking anything else down the line.
Hi, yes I'm all sorted now.
(edited)
I've also added the ability to recurse into sub-pages for searching in my code so a search from /news also searches in /news/current-affairs and /news/celebrity.
I'm unsure as yet how I'll make this available to others but I think it might be useful.
Steve.
(edited)
I've also added the ability to recurse into sub-pages for searching in my code so a search from /news also searches in /news/current-affairs and /news/celebrity.
I'm unsure as yet how I'll make this available to others but I think it might be useful.
Steve.
Below is the revised code with the line commented out which allows the value to be set.