Category placeholders in auto-nav
Permalink 1 user found helpful
Hi all,
I'm sure I've seen people in the past asking how to have section headings in the auto-nav that just open up for pages below but that do not have any content.
I was just looking at this for a site and thought I'd share my solution - if there is a better/easier/default way of doing this that I've missed then please don't hesitate to slap me round the head, call me a silly boy and post it below!
Basically we want the href of a menu item to be "javascript:void(0)", but we also want to show the section in the url path.
In the Concrete5 admin area go to Pages and Themes/Attributes
and add a new page attribute of type checkbox with the handle 'placeholder'.
Copy concrete/blocks/autonav/view.php
to /blocks/autonav/view.php
edit /blocks/view.php (so as not to change the core code).
Find the following code:
if (!$pageLink) {
$pageLink = $ni->getURL();
}
and add this after it
if ($_c->getCollectionAttributeValue('placeholder')) {
$pageLink="javascript:void(0)";
}
this little snippet of code checks to see if your custom attribute is active and if it is adds the javascript.
All you need to do then is apply the custom attribute to your pages.
Like I said - there may be another way of doing this but this way doesn't mess up the path and allows page permissions to cascade nornmally.
I'm sure I've seen people in the past asking how to have section headings in the auto-nav that just open up for pages below but that do not have any content.
I was just looking at this for a site and thought I'd share my solution - if there is a better/easier/default way of doing this that I've missed then please don't hesitate to slap me round the head, call me a silly boy and post it below!
Basically we want the href of a menu item to be "javascript:void(0)", but we also want to show the section in the url path.
In the Concrete5 admin area go to Pages and Themes/Attributes
and add a new page attribute of type checkbox with the handle 'placeholder'.
Copy concrete/blocks/autonav/view.php
to /blocks/autonav/view.php
edit /blocks/view.php (so as not to change the core code).
Find the following code:
if (!$pageLink) {
$pageLink = $ni->getURL();
}
and add this after it
if ($_c->getCollectionAttributeValue('placeholder')) {
$pageLink="javascript:void(0)";
}
this little snippet of code checks to see if your custom attribute is active and if it is adds the javascript.
All you need to do then is apply the custom attribute to your pages.
Like I said - there may be another way of doing this but this way doesn't mess up the path and allows page permissions to cascade nornmally.
I just bumped into a few problems; couldn't get it working right.
So i thought i'd tell you guys what went wrong in case anyone faces the same dilemma:
if ($_c->getCollectionAttributeValue(‘placeholder’)) {
$pageLink=”javascript:void(0)”;
}
the double quotes should be single quotes in the second line; and if you copy paste the lines; for some reason it doesn't read the single quotes in the first line either... so you'll have to delete them and type them in yourself!
if ($_c->getCollectionAttributeValue(‘placeholder’)) {
$pageLink='javascript:void(0)';
}
took me a while to spot the problem but i hope this saves someone the time and trouble !