Creating a jump menu with auto nav block
Permalink 1 user found helpful<?php defined('C5_EXECUTE') or die("Access Denied."); $aBlocks = $controller->generateNav(); $c = Page::getCurrentPage(); echo("<div class='site_quick_jump_container'>"); echo("<form id='find_branch_footer' class='site_quick_jump_form' method='get' action=''>"); echo("<label for='find_branch_footer'></label>"); echo("<select name='fb_list' id='fb_list' class='site_quick_jump' title=''>"); echo("<option value=''>Find your branch</option>"); $nh = Loader::helper('navigation'); $isFirst = true; foreach($aBlocks as $ni) { $_c = $ni->getCollectionObject(); if (!$_c->getCollectionAttributeValue('exclude_nav')) { $target = $ni->getTarget();
and here is my javascript....
<script type="text/javascript" charset="utf-8"> //<![CDATA[ $(document).ready(function() { $('.site_quick_jump').change(function(){ // option 1 use a JS redirect in the current window //window.location.href = $(this).val(); // option 2; set the 'action' of the form and submit it if ($(this).val() != '') { $('.site_quick_jump_form').attr('action', $(this).val()); // $('.site_quick_jump_form').attr('target', '_self'); // new window $('.site_quick_jump_form').submit(); // Go! } }); }); // doc ready //]]>
I can get the form field to show up, but the option fields do not populate from the sitemap. Any suggestions?
if ($isFirst) $isFirstClass = 'first'; else $isFirstClass = ''; echo '<option class="'.$navSelected.' '.$isFirstClass.' selected="selected">'; if ($c->getCollectionID() == $_c->getCollectionID()) { echo('<option selected="selected" value="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</option>'); } else { echo('<option value="' . $pageLink . '" ' . $target . '>' . $ni->getName() . '</option>'); } echo('</option>'); $isFirst = false;
Here is a suggested change (replace the snippet above with just the code below):
Do the pages that you want to populate into the option values have the custom attribute 'exclude_nav' set as false (unchecked)?