Navigation breaking

10 posts by 3 authors in: Forums > CMS Builder
Last Post: August 13, 2012   (RSS)

Re: [dsternalski] Navigation breaking

Hi dsternalski,

Do you have 'allowSearch' => false, in your get records call?

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] Navigation breaking

Hi,

Yes I have in the getRecords call but not in the getCategories call.

Re: [dsternalski] Navigation breaking

By Jason - August 8, 2012

Hi,

The issue here is that in your first foreach loop, you're not outputting all your records. You're only outputting records where "is_feature" is selected. You probably need an "else" for outputting records where that is not set.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Navigation breaking

Hi,

In the first for each loop, I have an ! (explanation mark) before the variable as I'm trying to output all records except those that have is_feature = 1.

Re: [dsternalski] Navigation breaking

By Jason - August 8, 2012

Hi,

You're right, I misread that.

getCategories creates the listItemStart and listItemEnd pseudo fields that contain all the <ul> and <li> tags to produce a nested list. When you filter out some records, it's throwing these tags off, so certain records are being nested when they shouldn't be. Currently, there isn't a good way to filter category records using a field value.

One option would be to output all records. If a record is featured and you don't want to display it, you could add CSS to it's <a> tag to set display to none. That way it doesn't show up, but the nesting stays correct.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Navigation breaking

Hi,

I will give that a try, but I have a feeling that although it will hide the <a> tag, that it won't hide the <li> tag, leaving a slight height in the empty <li>.

I have used code like this before to hide features in the navigation & it worked fine in an older version of the CMS, so I'm wondering if possibly where the code behind the CMS has been updated that it now doesn't work.

Re: [dsternalski] Navigation breaking

By Jason - August 9, 2012

Hi,

Another approach would be to change your "is_featured" check box to a "hidden" checkbox. This way, all those records will be filtered out by default by the getCategories() call, so the nesting should remain in tact. Also, you wouldn't need an if statement in your foreach loop.

When you needed those records to show up, you could use the
'ignoreHidden' = true,

option.

Hope this works.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Navigation breaking

By dsternalski - August 11, 2012 - edited: August 11, 2012

I already have a 'hidden' checkbox, and I can't really use this not to display hidden as this will affect other pages.

I have tried this:

<?php foreach ($allIndex_homeRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart']; ?>
<?php if(!$categoryRecord['is_feature']): ?>
<span <?php if($thisPage == "index"){echo 'class="currentpage"';} ?>><a href="<?php echo $categoryRecord['_link']; ?>"><?php echo $categoryRecord['name']; ?></a></span>
<?php endif; ?>
<?php echo $categoryRecord['_listItemEnd']; ?>
<?php endforeach; ?>

And although it doesn't break the navigation, it doesn't completely remove the empty <li>'s.

Attached is an image of what I mean.
Attachments:

empty-li.png 67K

Re: [dsternalski] Navigation breaking

By Jason - August 13, 2012

Hi,

Another option is to get the display:none style into the li/ul tags

First add this function to your page:

function hideFeaturedCategories($category) {

if ($category['is_featured']) {
return "style = 'display:none'";
}

return;
}



Then you can call this function using the li and ul attributes callback options in getCategories

EXAMPLE:

'liAttributesCallback' => 'hideFeaturedCategories',
'ulAttributesCallback' => 'hideFeaturedCategories',


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/