Category subnav changing based on url

11 posts by 3 authors in: Forums > CMS Builder
Last Post: November 29, 2012   (RSS)

I have had trouble with this twice now, the first time I was able to manually remedy the issue, but I cannot this time.

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

Hi clowden,

It's always helpful when you provide the code.

Could you attach your list and detail viewers to a post?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







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

Knew I should have done that in the first place. Thank you.

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.
Attachments:

detail_009.php 3K

index_049.php 5K

Re: [clowden] Category subnav changing based on url

Hi Clowden,

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!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Category subnav changing based on url

Sorry about that Greg, didn't think about including that. File uploaded.
Attachments:

subnav-inc.php 1K

Re: [clowden] Category subnav changing based on url

Hi Clowden,

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
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Category subnav changing based on url

Thank you very much for your help.

I added the code to my detail.php page and got nothing. Didn't get an error either. Any ideas?

Re: [greg] Category subnav changing based on url

It is not returning anything at all (errors or empty array), its doing the exact same thing it was before. I pasted it over what I had yes.

Re: [clowden] Category subnav changing based on url

Could you fill out a second level support request and I can take a closer look at how you have your sections set up? You will need to fill out this form:


https://www.interactivetools.com/support/email_support_form.php


Thanks!
Greg Thomas







PHP Programmer - interactivetools.com