Page hierarchy: pass-through pages?
Permalink
Imagine a navigation with an item that, when clicked on, takes you to its first child page.
So it isn't necessary that the top-level page exists (except in the navigation).
You click on "page" but instead of going to
/page
you go to
/page/first-child
How would this be set up, ideally?
Thanks for your help!
So it isn't necessary that the top-level page exists (except in the navigation).
You click on "page" but instead of going to
/page
you go to
/page/first-child
How would this be set up, ideally?
Thanks for your help!
If you understand German, I've posted an approach on Concrete5.ch:
http://www.concrete5.ch/board/?topicID=21...
http://www.concrete5.ch/board/?topicID=21...
I can't read German, but I guess Google Translator does a passable job. Totally messes up the code, though :-)
So I get this from that thread (taking out the conditionals...):
But it doesn't work, giving me this error:
Fatal error: Call to a member function getCollectionPath() on a non-object in [...]/concrete/helpers/navigation.php on line 36
I bet this would be easy if only I knew what I was doing :-)
So I get this from that thread (taking out the conditionals...):
$nh = Loader::helper('navigation'); $subPage = $c->getFirstChild(); $pageLink = $nh->getLinkToCollection($subPage); print("the child link: " . $pageLink);
But it doesn't work, giving me this error:
Fatal error: Call to a member function getCollectionPath() on a non-object in [...]/concrete/helpers/navigation.php on line 36
I bet this would be easy if only I knew what I was doing :-)
the function which gets called should have a parameter, $page in my example.
I think it should be $page->getFirstChild()
(haven't tested it)
I think it should be $page->getFirstChild()
(haven't tested it)
Whoops, turns out the previous code *did* work.
So, if anyone wants to force a page to go to its first child page this code at the very top of a page type will do the trick:
Not sure what would happen if the first child happened to be an external link (not a page). Use with caution.
Thanks for your help, Remo!
ps - if there is a way to do this with c5's core (aliases?) I'd love to know about it.
So, if anyone wants to force a page to go to its first child page this code at the very top of a page type will do the trick:
Not sure what would happen if the first child happened to be an external link (not a page). Use with caution.
Thanks for your help, Remo!
ps - if there is a way to do this with c5's core (aliases?) I'd love to know about it.
thanks kirk,
the code needs a minor fix though...
the code needs a minor fix though...
Hi, I copied your code Kutis and it works but now my parent link is not selected as active.
It has an 'a' class of 'nav-path-selected' but so does the 'home'. So if i add a style to that class both the home and portfolio page will have the selected class.
am i doing something wrong?
It has an 'a' class of 'nav-path-selected' but so does the 'home'. So if i add a style to that class both the home and portfolio page will have the selected class.
am i doing something wrong?
I tried copying this and it wouldn't work. I basically want the top-most link (parent link) to be inactive on the navigation. So far, I haven't been able to find anything that works.
the site ishttp://www.hawkletsxc.org/c5dev and what the coach wants is for the parent item in the navigation to not link to anything or somehow link to '#'.
the site ishttp://www.hawkletsxc.org/c5dev and what the coach wants is for the parent item in the navigation to not link to anything or somehow link to '#'.
@mbayhylle
If I understand you correctly, this technique won't work for what you're trying to do. This is only if you want the parent item to still be a link, but have it link to the first child item (so two links in the nav go to the same page). The code above is a safeguard in case someone types the address of the parent item in, or has a direct link to it somehow. Otherwise, the auto-nav block can take care of the linking (see the first comment in this thread).
I'm not sure why someone would want a nav link to not go anywhere. As a user I find that frustrating. But I understand you might not be calling the shots :-)
For what you're trying to do, if all top links are to be inactive you could potentially template the auto-nav block to do that. Have it omit the link tags on the first pass through.
If I understand you correctly, this technique won't work for what you're trying to do. This is only if you want the parent item to still be a link, but have it link to the first child item (so two links in the nav go to the same page). The code above is a safeguard in case someone types the address of the parent item in, or has a direct link to it somehow. Otherwise, the auto-nav block can take care of the linking (see the first comment in this thread).
I'm not sure why someone would want a nav link to not go anywhere. As a user I find that frustrating. But I understand you might not be calling the shots :-)
For what you're trying to do, if all top links are to be inactive you could potentially template the auto-nav block to do that. Have it omit the link tags on the first pass through.
As an alternative, you could use css to make the top-level links *appear* not to be links:
.nav > li a:hover { cursor: default; }
.nav > li a:hover { cursor: default; }
If you look at the left menus on this site...
http://thenorthernbeaches.com.au...
..the main links are simply category headers.
Most other cms allow for the creation of such links, I think it would be handy to have this capability in Concrete5. The alternative is to go to a sub-page listing the sub-categories, but I find this a bit superfluous?
http://thenorthernbeaches.com.au...
..the main links are simply category headers.
Most other cms allow for the creation of such links, I think it would be handy to have this capability in Concrete5. The alternative is to go to a sub-page listing the sub-categories, but I find this a bit superfluous?
I think this is the same question/problem I'm having so I'm just posting in this thread until I have time to read it (so it is easier for me to find this page again later on)... hope you found a solution.
I want my Parent to redirect to the first Child in my Breadcrumbs navigation.
I want my Parent to redirect to the first Child in my Breadcrumbs navigation.
Awesome! For anyone who doesn't understand, this works for DIRECT LINKING (as opposed to auto-nav). For the auto-nav to redirect to the First Child, you need to add the attribute "replace_link_with_first_in_nav" as a checkbox and then add add it it to your Parent as a Custom Attribute.
BUT, if you're going to have other kinds of linkage beside an auto-nav that you want to redirect to that First Child, too, then you just make a special Page Type for that Parent and the full template is basically this code Kirk has come up with. But, as Kutis pointed out, you need to wrap it in <?php ?> tags, obviously.
Thank you!
BUT, if you're going to have other kinds of linkage beside an auto-nav that you want to redirect to that First Child, too, then you just make a special Page Type for that Parent and the full template is basically this code Kirk has come up with. But, as Kutis pointed out, you need to wrap it in <?php ?> tags, obviously.
Thank you!
How do you add this "replace_link_with_first_in_nav" attribute? I can't seem to find it anywhere.
Thanks!
Thanks!
First you need to create the page property/attribute.
In the admin area / dashboard look for Page Types and Page Attributes.
There you can create a checkbox/boolean attribute and make sure the attribute handle matches the replace_with_first_.... text (sorry, forgot to copy exactly what it is before I started replying :-)
Then on any given page in the Page Properties you can select that attribute.
Does that help?
In the admin area / dashboard look for Page Types and Page Attributes.
There you can create a checkbox/boolean attribute and make sure the attribute handle matches the replace_with_first_.... text (sorry, forgot to copy exactly what it is before I started replying :-)
Then on any given page in the Page Properties you can select that attribute.
Does that help?
Yup, works perfectly, thanks so much!
Thank you so much for this information! How did you figure out that there is a handle that does this functionality? Is there some file that has a list of inactivated handles?
DtotheOR, for me it's just been a lot of looking around the forums and digging around in the core files.
I think that property was suggested early on by a power user (Remo?) and the Concrete5 team eventually added it to the core.
I think that property was suggested early on by a power user (Remo?) and the Concrete5 team eventually added it to the core.
But I'm also wondering if this is possible:
With a structure like this...
/section/
/section/page/
*any* link to /section/ will go to /section/page/.
eg if someone types it in
How can this be achieved?