Summary: A pull down menu that can be used for navigation
Version: 1.0
Prerequisites: Latest version of PmWiki
Status:
Maintainer:
Questions answered by this recipe
Q. How do I make a select box that automatically jumps to the page I select?
A. Use the Jumpbox recipe, of course.
How to Use
1. Download and enable the jumpbox.phpΔ recipe by adding the following to your config.php file:
include_once "$FarmD/cookbook/jumpbox.php";
2. Create a pagelist template that looks like the following:
[[#jumpbox]]
(:template first:)
(:input jumpbox value='' label='Select One...':)
(:template each:)
(:input jumpbox value="{=$PageUrl}" label="{=$Title}":)
[[#jumpboxend]]
3. Create a pagelist like the following
(:pagelist group=Main fmt=#jumpbox:)
Notes
I just copied this from the page Pm put up at http://www.pmwiki.org/wiki/Test/JumpBox.
Contributors
Comments
I keep getting the following error
Fatal error: Call to undefined function InputSelect() in /var/www/vhosts/ilovemacaroniandcheese.com/httpdocs/pmwiki/pmwiki.php(1239) : regexp code on line 1
Any ideas? --DavidBessler? July 12, 2007, at 10:26 PM
Ditto...Anyone? --BarryKenee? October 29, 2008, at 12:43 PM
You say download and enable jumpbox.php, I know how to download it but how do I enable it?
I added instructions for enabling the recipe above XES August 25, 2008, at 11:17 AM
This recipe works fine on some websites but when the URL is ?n=Group.Page it doesn't work. Script needs to take $ScriptUrl into account and whether clean URLs are enabled or not, and form proper URLS.... don't know how to change the Javascript myself.... XES August 25, 2008, at 11:20 AM
Created a solution. See below:
Jump to any Group/Pagename
This solution gets around using "Group/Pagename" for the jump targets & works only with $EnablePathInfo = 1. You must specify Group, you may use Group without PageName and PmWiki will select the default page for the group, per usual.
<?php if (!defined('PmWiki')) exit();
$HTMLHeaderFmt['jumpbox'] =
"<script type='text/javascript'><!--
function jump(postfix)
{
var destination = '$ScriptUrl/' + postfix;
window.location.href = destination;
}
//-->
</script>
";
$FmtPV['$_UniqId_'] = '($GLOBALS["_UniqId_"] = uniqid("id"))';
$FmtPV['$_PrevId_'] = '$GLOBALS["_UniqId_"]';
$InputTags['jumpbox'] = array(
'name' => 'n',
':html' =>
"<form action='{$PageUrl}' method='get'>
<select onchange='jump(this.options[this.selectedIndex].value)'
\$InputSelectArgs class='inputbox' >\$InputSelectOptions</select>
<input id='{\$_UniqId_}' type='submit' value='$[Jump to page]' class='inputbutton' />
<script type='text/javascript'><!--
document.getElementById('{\$_PrevId_}').style.display = 'none';
//--></script></form>");
Markup('input-jumpbox', '<split',
'/\\(:input\\s+jumpbox\\s.*?:\\)(?:\\s*\\(:input\\s+jumpbox\\s.*?:\\))*/ei',
"InputSelect(\$pagename, 'jumpbox', PSS('$0'))");
20081006
My wiki uses clean url's and I like this recipe. It works well with the pagelist directive but using it manually as
(:input jumpbox value=Main.HomePage:)
doesn't work. I played around with it and finally got it to work perfectly using
(:input jumpbox value={$ScriptUrl}/Main.HomePage label="Home Page":)
You have to use the label= option or else the entire url is shown in the button.
Ian MacGregor
UPDATE: Oops, spoke too soon. This recipe, "out-of-the-box", breaks validation on my site so I won't be able to use it.
Ian MacGregor