Redirect Parent Page to FIRST child page1 user found helpful
--About Product 1
In this case they would want 'Product 1' to redirect to 'About Product 1' so that the parent page is never seen.
Is this possible in the concrete5 dashboard?
I'm doing this:
<a href="<?=$this->url('print/ads');?>" rel="dropmenu1">Print</a>
$child = $c->getFirstChild(); $cID = $child->getCollectionID(); header('Location:' . Page::getCollectionPathFromID($cID));
I had a need to do this rather than using the "replace_link_with_first_in_nav" because I wanted all pages of a certain type redirect to their child pages. This was used for a set of drop down menus. I wanted users to be able to add more menus, but force those pages to do the redirect rather than requiring the attribute to be set on each page.
The problem now is that i still have the "index.php" in the URL as it is on a development server. But the url that comes out of getCollectionPathFromID($cID) is just the part from after "index.php".
I guess this will probably work when I enable pretty URL:s but then it shouldn't have worked before either. I just want to know how it can work the first times and then nothing, now I just get the 404.
Any ideas are appreciated, thanks!
If you are looking for the link to the page you should use
or if you need the full path with the domain
I didn't get that to work either, then again I might be doing it wrong. But is there a way to get the full path with domain using the $cID ? $page wasn't the same as $cID as I first thought.
$page = Page::getByID($cID); Loader::helper('navigation')->getLinkToCollection($page, true);
That did the trick. =)
Thanks @aghouseh, wasn't clear enough in my description.