Category subnav changing based on url
11 posts by 3 authors in: Forums > CMS Builder
Last Post: November 29, 2012 (RSS)
By clowden - November 26, 2012
I have a subnav created with the category function, that is all working fine. The issues is when I click a link to go to my detail page, the subnav changes based on the record number in the url (image attached). As you can see the "Online Exhibitions" second level links are active, they should not be. The active page should be "Online Collections" but because the url is pulling record 10 the navigation believes one of the other items are selected.
Hope this all makes sense, if needed I can provide code.
Re: [clowden] Category subnav changing based on url
It's always helpful when you provide the code.
Could you attach your list and detail viewers to a post?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Category subnav changing based on url
By clowden - November 27, 2012
Detail.php is the page I am running into the issue. I know this is an easy fix, I just can't seem to find it.
Re: [clowden] Category subnav changing based on url
I've had a look at your code, but I can't see where your using the $subNav variable. I guess it's in the footer or subnav.inc.php files? Would it be possible to attach these as well?
Thanks!
PHP Programmer - interactivetools.com
Re: [greg] Category subnav changing based on url
By clowden - November 27, 2012
Re: [clowden] Category subnav changing based on url
I've done some local testing and looked at your code, I think something like this should work:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'admin/lib/viewer_functions.php';
$dirsToCheck = array('/home7/mizrahio/public_html/hunt_dev/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load page content
list($page, $pageMetaData) = getRecords(array(
'tableName' => 'online_collections',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$page = @$page[0]; // get first record
list($navData, $navMetaData) = getRecords(array(
'tableName' => 'archives',
'where' => whereRecordNumberInUrl(1),
'limit' => '1'
));
$navData = @$navData[0]; // get first record
//find the top level navigation num value
$selectedCat = explode(':', $navData['lineage']);
$selectedCat = $selectedCat[1];
list($subnav, $subnavCategory) = getCategories(array(
'tableName' => 'archives',
'defaultCategory' => 'first',
'selectedCategoryNum' => $selectedCat,
'categoryFormat' => 'onelevel',
));
?>
So the green getRecord statement finds the currently selected menu item, and then finds the top level entry it's linked too from the lineage field and stores it against the $selectedCat variable.
In the getCategories function I've added the selectedCategoryNum key, which lets the getCategories function know which is the current parent category.
Let me know if you have any problems.
Thanks
PHP Programmer - interactivetools.com
Re: [greg] Category subnav changing based on url
By clowden - November 28, 2012
I added the code to my detail.php page and got nothing. Didn't get an error either. Any ideas?
Re: [clowden] Category subnav changing based on url
Is it returning an error or an empty array at all? Did you paste this code over the code that is currently at the top of your page?
Thanks!
PHP Programmer - interactivetools.com
Re: [greg] Category subnav changing based on url
By clowden - November 29, 2012
Re: [clowden] Category subnav changing based on url
https://www.interactivetools.com/support/email_support_form.php
Thanks!
PHP Programmer - interactivetools.com