Auto-Nav Parent without link

Permalink 1 user found helpful
Not sure how to word this properly. In a drop down menu the top level link is to a page. The forums talk about hiding the parent but this request is the opposite.

I want the parent to show but not link to a page. If someone clicks on that link it should do nothing. They have to select one of the children links to see a page. It appears that navigation menu items only reflect pages. But it doesn't make sense to click on an empty page. The top level links like the about page may point to a specific page but list items with children should disabled at the top level and only the children link to pages.
bhat
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
If you want to make the top-level links non-clickable, you'd need to create a custom template, which would require some decent php coding to figure out.

But an alternate solution that many people use is making it so clicking on one of those top-level links goes to the first sub-page -- this can be done fairly easily with the "replace_link_with_first_in_nav" page attribute. First you need to create this attribute by going to Dashboard -> Pages and Themes -> Attributes, choosing "checkbox" from the dropdown menu and clicking the "Add" button. For the handle, paste in this:
replace_link_with_first_in_nav

And for the name enter "Replace Link With First In Nav". Don't worry about the other settings. Click the "Save" button.

Now, go to those top-level pages and set this attribute for each one by editing the page, clicking "Properties" in the toolbar, clicking the "Custom Attributes" tab, choosing "Replace Link With First In Nav" from the "**Add Attribute" dropdown, checking the box, and saving.

Hope that helps!

-Jordan
jordanlev replied on at Permalink Reply
jordanlev
Actually, I just found this in my list of links -- the explanation is a bit clearer:
http://www.concrete5.org/index.php?cID=125451#127655...
bhat replied on at Permalink Reply
bhat
Fantastic, first-link was my second thought. Currently, focusing on the auto-nav feature, the forums have been a great help.

I have thought about compiling some of the questions and answers in a single document. Would that be considered plagiarism? It seems like auto-nav is one of the most questioned features. There are a lot of questions about specific tweaks so maybe bringing some of them together would help others. My skill level is still a bit lite but maybe I could put it together and get some more experienced people, such as yourself, to review and critique. Of course, that is if aggregating forum answers is not plagiarism or considered unethical. It would be a bit clumsy if credits had to be applied to each answer so maybe a generic credit to all forum responders would be good enough?
jordanlev replied on at Permalink Reply
jordanlev
I wouldn't consider it plagiarism as long as you credit the authors and/or make it obvious that each answer is by someone else. (And aren't charing money for it). Linking to the original forum posts for each answer would be a good idea -- it would make it clear who the author is and also would allow people to see the full post for more context if they wanted.

I'd be happy to look over anything like that you want to put together. And I think it's great that you want to collect these and try to help others. The biggest challenge with these things, though, is how do people find it? There are already quite a number of small little half-completed documentation projects floating around, and without some central organization it's likely it will just get lost in the shuffle. Perhaps you could write it up more as a how-to and submit it to the Concrete5 documentation itself -- at least then it's in a central place and can be searched?

-Jordan
pranaman replied on at Permalink Reply
I have the same request as bhat. I am looking through as much as I can to make that happen.

Regarding a link below, and not to step on any toes, I think think the following plug-in should inspire the creation of a similar item for us:

wordpress.org/extend/plugins/disable-parent-menu-link/.
jordanlev replied on at Permalink Reply
jordanlev
This is a good idea.
In the meantime, I've used JavaScript to disable certain links, or you could use the technique mentioned in the link above where you create an "external link" page in the sitemap whose URL us just "#", and put subpages under there.
jordanlev replied on at Permalink Reply
jordanlev
I've updated my custom autonav template to include this functionality:
https://github.com/jordanlev/c5_clean_block_templates/blob/master/au...

See this blog post for instructions on how to use it:
http://c5blog.jordanlev.com/blog/2011/12/customizing-the-autonav-te...
pranaman replied on at Permalink Reply 1 Attachment
I am thrilled that this is here. Thanks for making it.

I am close to figuring how to use it, but I am missing something.

I created the siteroot/blocks/autonav folder and
I copied the view.php file to that folder

Not sure what to do now. I clicked it, and then clicked 'Custom Template'. There I saw: Header Menu and Breadcrumbs

Tried them both, not there yet. ... a checkbox for the disabling effect to work.

I think you mean to be in the Page Attributes area. I am there now, but some details I don't know what to do as there are some values I'm sure if I should change them.

If you don't mind, please provide more detail as to what to do in C5 5.5.0 after copying the php file to the server?

Thank you.
pranaman replied on at Permalink Reply 2 Attachments
Fairly confident I found a C5 5.5.0 BUG.

I was in the Page Attributes page, and not sure of which settings to use. I took a chance and added it, as shown in the pic from the above post.

I went to the sitemap, and then to the page where I wanted to disable the nav link, but it did not have the checkbox.

So, I thought it would easy enough to delete. Wrong.

I went back to Page Attributes, tried to delete it, and it showed the *File Attributes* page with an "Invalid attribute id" error.

It did not show the *Page Attributes* page.

Somehow it's confused the two.

Also, the little drop down area when you hover near the top, that shows "attributes" and "attributes" (see second file). I think they need to be distinguished.

Please look into this matter. Thank you.
jordanlev replied on at Permalink Reply
jordanlev
I think you misunderstand my role here -- I am not a C5 developer, just someone helping out on the forums. If you found a bug you should submit a Bug Report.:
http://www.concrete5.org/developers/bugs/...

(Perhaps English is not your native language, but saying "please look into this matter" sounds like a command -- like you are my boss at a job).
jordanlev replied on at Permalink Reply
jordanlev
The way that custom template overrides work in Concrete5 is that you can either completely override the default template, or you can make a separate custom template that is chosen from the 'Custom Template' dropdown menu. By simply naming this file "view.php" and putting it in SITEROOT/blocks/autonav, you are overriding the default template -- which means C5 is using that new file instead of the built-in one automatically, without you having to choose it from the list.
It is good that you didn't see anything change when you put this file on your server -- that means it's working! It is intended to provide cleaner HTML, CSS, and PHP code for designers/developers to work with.

But in your case, you just want this ability to denote that a page should not be "clickable" in the menu, and if you look at the comments at the very top of that file, you'll see some explanation of different attributes you can use. The 4th one is new (I just added it, based on your feedback). To make it work, add a new attribute to your system via the "Page Attributes" dashboard page (in 5.4, go to Dashboard -> Pages and Themes -> Attributes, or in 5.5 type "page attributes" into the intelligent search box). Once there, look down at the bottom where it says "Add Attribute", and choose "checkbox" from the list (or it might be called "Boolean" in 5.5), then click the add button. Now for the handle, enter "disable_link_in_nav", and for the name enter "Disable Link In Nav". Leave everything else as-is, then click the "Add" button.

Now you should have the "Disable Link In Nav" attribute available in the Custom Attributes section when you edit a page's properties. Note that it will turn your links into html "spans", which means the styling might get messed up -- you'll need to address this in your theme css if it's a problem.

Let me know if that works for you.
pranaman replied on at Permalink Reply
Sorry, did not intend it to sound like any kind of command. I certainly am not your boss.

It just takes a long time to figure out some of the smallest of things, and it gets incredibly frustrating to do so.

I will report the bug to the bug place, was not sure where that was until now. Thank you for all your help. I will continue onward.
pranaman replied on at Permalink Reply
Regarding the latter post - the directions are a lot clearer.

I now know what to do and what I did wrong.

I am running 5.5, and I see now that Boolean was the option to have chosen. I did not. I already created it and chose another option.

I don't see a way to change it to Boolean now that I have created it and I still can't delete that sucker.

Thanks for the better directions and all the help. I will try to fix it and report that I cannot change it and the other issue towww.www.concrete5.org/developers/bugs/5-5-2/....
jordanlev replied on at Permalink Reply
jordanlev
Yeah, I saw that the name "checkbox" got changed to "Boolean" in 5.5 and reported that as a bug myself because normal people don't know or care what "Boolean" means.

You cannot change the type of an attribute once it is already created -- you will have to delete it and create a new one.
pranaman replied on at Permalink Reply
Yeah, got it now. I just upgraded from 5.5.0 to 5.5.2 and then I was able to delete it.

Thought I was running 5.5.1, forgot I did a fresh reinstall with 5.5.0.

Something else broke after upgrading, but at least I am able to delete the attribute. I will readd it soon, and hopefully it'll all work.
pranaman replied on at Permalink Reply
I added the attribute, went to the 'About' page's properties, and it was there in Custom Attributes.

I clicked it - "Disable Link In Nav".

I then tried it, reloading the page, and clearing the cache, but the About link still loads the page when clicked.
jordanlev replied on at Permalink Reply
jordanlev
Hmm... not sure what the problem could be. I just updated the free "Autonav Exclude Subpages" addon in the marketplace to utilize this new template, so you might want to try installing that and see if that works (note that for that to work, you need to click on the autonav block and choose "Custom Templates", then pick "Exclude Subpages" from the list):
http://www.concrete5.org/marketplace/addons/autonav-exclude-subpage...

Also, note that there's a pretty major bug in 5.5.2 that might be what is causing you other things to break:
http://c5blog.jordanlev.com/blog/2012/04/fixing-func-get-args-bug-i...
pranaman replied on at Permalink Reply
OK, I got it to work. Kind of.

Installed the 'Exclude Subpages' template, and it did disable the About link. But my drop downs are gone:http://www.mytrucklube.com/index.php?cID=128....

However, in my previous attempts I created another custom template, using Sooperfish - I was googling how to disable the parent link and that came up. I followed those instructions, and made a custom template.

Somehow I used it, and snazzied-upped my autonav, but the custom attribute of the link-disabling effect from earlier did not work.

When I installed, then changed to the 'Exclude Subpages' template, the sooperfish one went away of course, and all the drop downs are now gone as well.

How do I have it all snazzy looking, maybe I missed that somewhere, and with the parent menu disabling effect of your addon (thank you again for making by the way)?
jordanlev replied on at Permalink Reply
jordanlev
Unfortunately I don't have an easy answer for you. If the dropdowns stopped working, it might be because the CSS styles of the dropdown menu that you're using is not designed to deal with disabled links. In the template I made, disabled links are outputted as <span> tags instead of <a> tags, and it is not a common thing to even have disabled links in nav menus so I am guessing your CSS is not styling the <span> tags as needed. You will either need to modify your dropdown CSS to make it work with the spans, or you could change the template so it outputs <a> tags that go nowhere instead of spans (by setting the "href" of those disabled <a> tags to "#" instead of the URL).
Creating dropdown menus is always a challenge I've found -- requires a lot of experimentation.

Good luck.

-Jordan
pranaman replied on at Permalink Reply
Hey, had an insight. Since I upgraded from 5.5.0 to 5.5.2 and now have the siteroot/updates/concrete5.5.2/concrete directory (thanks Ekko). Does that change anything?

I backed up the view.php that was there, and added the new one from your site - no changes, but I thought I might be on to something...
jordanlev replied on at Permalink Reply
jordanlev
The updated c5 system directory should not have any effect on this, because you're overriding the built-in template, not replacing the file itself. Although... just to be sure, you're working in the SITEROOT/blocks/autonav/ directory, correct?
pranaman replied on at Permalink Reply
That's good to know.

Still at it, and yes, I am in the siteroot/blocks/autonav directory. Thanks for double-checking.
thephilm replied on at Permalink Reply
thephilm
I've used in the past a bit of jQuery to selectively remove the linking from an autonav...
Here's the code
<script>
  $(document).ready(function(){
   $('a[href$="/your-link-that-you-want-removed/"]').removeAttr('href');
  });
</script>

Just make sure to put it in the footer (after jquery is called) ...
In jQuery the "$=" looks only for a matching link at the end of the link's url, so it shouldn't affect your subpages.

Hope this helps!
- Phil
markonedesign replied on at Permalink Reply
markonedesign
Many thanks Phil for your script - works a treat in 5.5.2.1

One question, I am using this script to disable five parent links, so have pasted five amended script snipits into my footer. Is there a way to combine into one script?

Cheers,
Mark
thephilm replied on at Permalink Reply
thephilm
I'm no jQuery expert, but here's how I would do multiple links:
<script>
  $(document).ready(function(){
   $('a[href$="/your-link-that-you-want-removed/"]').removeAttr('href');
$('a[href$="/your-link-that-you-want-removed2/"]').removeAttr('href');
$('a[href$="/your-link-that-you-want-removed3/"]').removeAttr('href');
$('a[href$="/your-link-that-you-want-removed4/"]').removeAttr('href');
  });
</script>
webicine replied on at Permalink Reply
webicine
Phil, That's awesome! Thanks so much.