[pmwiki-users] broken GeminiSkin with beta29
Hans
design at softflow.co.uk
Sat Feb 25 10:04:10 CST 2006
Saturday, February 25, 2006, 12:37:38 PM, Patrick wrote:
> I've just released beta30, which fixes the problem with $SearchBoxFmt
> introduced by beta29.
Thanks! Works great now. We got a power searchbox now!
>> I would like to take advantage of the new
>> searchbox capabilities, just need to know how to create a format which
>> suits the skin and can take additional parameters.
> Beta 30 doesn't let $SearchBoxFmt take additional parameters -- I'll
> add that for beta 31. (Unfortunately I don't have time to add it now,
> but I at least wanted to fix the current release so that existing
> skins don't break.)
I don't know how easy or difficult that is. To get the desired look
and functionality I had to add to the Searchbox function.
What I just did is to redefine the searchbox markup to call a
redefined Searchbox function, in skin.php:
function SearchBox2($pagename, $opt) {
global $SearchBoxFmt, $SearchBoxOpt, $SearchQuery, $EnablePathInfo;
if (isset($SearchBoxFmt)) return Keep(FmtPageName($SearchBoxFmt, $pagename));
SDVA($SearchBoxOpt, array('size' => '40',
'label' => FmtPageName('$[Search]', $pagename),
'value' => str_replace("'", "'", $SearchQuery),
'focus' => 'true'));
$opt = array_merge((array)$SearchBoxOpt, @$_GET, (array)$opt);
$opt['action'] = 'search';
$target = ($opt['target'])
? MakePageName($pagename, $opt['target']) : $pagename;
$onfocusHTML = "onfocus=\"if(this.value=' {$opt['value']} ') {this.value=''}\"
onblur=\"if(this.value=='') {this.value=' {$opt['value']} '}\" ";
$out = FmtPageName(" class='wikisearch' action='\$PageUrl' method='get'>",
$target);
$opt['n'] = IsEnabled($EnablePathInfo, 0) ? '' : $target;
$out .= "<input type='text' name='q' value='{$opt['value']}'
class='inputbox searchbox' size='{$opt['size']}' ".
($opt['focus']=="true" ? $onfocusHTML : "")." />";
$out .= "<input type='submit' class='inputbutton searchbutton' value='{$opt['label']}' />";
foreach($opt as $k => $v) {
if ($v == '') continue;
if ($k == 'q' || $k == 'label' || $k == 'value' || $k == 'size') continue;
$k = str_replace("'", "'", $k);
$v = str_replace("'", "'", $v);
$out .= "<input type='hidden' name='$k' value='$v' />";
}
return '<form '.Keep($out).'</form>';
}
This adds onfocus and onblur to display a value like value="Search Site"
inside the box, and by clicking on the box removing it.
The focus= parameter is added, so when focus=0 is set any
value=parameter will stay in the box when clicking on it, as a prefix
value.
The above will show a default searchbox with (:searchbox:), and a
smaller searchbox with Go button with markup
(:searchbox label=Go value='Search Site':)
The change to the code is very similar to the change from newpagebox
to newpageboxplus.
Anyway, if you think this could be useful as default then I don't need
to bother to redefine it in the skin, otherwise I could.
And I am not sure if the function can be changed so a different pagebox can be
displayed with the above functionalty just through setting
$SearchBoxFmt.
One other thing:
Pmwiki's SearchBox function should have a line changed to read
class='inputbutton searchbutton' value='{$opt['label']}' />";
It reads class='inputbox... right now.
And one question:
Why does it say:
'value' => str_replace("'", "'", $SearchQuery),
and not
'value' => '',
The latter seems to work just as well.
Best,
~Hans
More information about the pmwiki-users
mailing list