get page name and URL via ID
Permalink 3 users found helpful
Hi I want to display a number of page names and their URLs in a template, I want to use the page ID so if they are changed at any point form the sitemap they will also update.
Can anyone provide the code, there are a number of instances of this on the template.
<a href="<?php echo $PageIDurl=70; ?>"><?php echo $PageID=70; ?></a>
<a href="<?php echo $PageIDurl=71; ?>"><?php echo $PageID=71; ?></a>
<a href="<?php echo $PageIDurl=72; ?>"><?php echo $PageID=72; ?></a>
<a href="<?php echo $PageIDurl=74; ?>"><?php echo $PageID=74; ?></a>
Thank you.
Can anyone provide the code, there are a number of instances of this on the template.
<a href="<?php echo $PageIDurl=70; ?>"><?php echo $PageID=70; ?></a>
<a href="<?php echo $PageIDurl=71; ?>"><?php echo $PageID=71; ?></a>
<a href="<?php echo $PageIDurl=72; ?>"><?php echo $PageID=72; ?></a>
<a href="<?php echo $PageIDurl=74; ?>"><?php echo $PageID=74; ?></a>
Thank you.
Hi Nick
Thanks for that, however that sheet is great for using if you need to manipulate the current page, but specifying another page is proving to be a bit more difficult, i.e. i don't want the current page name or its parent page name, i want a page name of an unrelated page.
Still an open question, answers greatly appreciated.
Thanks
Ben
Thanks for that, however that sheet is great for using if you need to manipulate the current page, but specifying another page is proving to be a bit more difficult, i.e. i don't want the current page name or its parent page name, i want a page name of an unrelated page.
Still an open question, answers greatly appreciated.
Thanks
Ben
Superb! Thank Jordan, just what I was after.
Perfect. Thank you very much kind sir Jordan!
I got it working perfectly for my needs, which was embedding the auto-nav in the theme columns of links in the footer. So for the About Section, I use auto-nav to display all it's sub-pages, and Jordan's code above to grade the parent page's name...in this case About.
I got it working perfectly for my needs, which was embedding the auto-nav in the theme columns of links in the footer. So for the About Section, I use auto-nav to display all it's sub-pages, and Jordan's code above to grade the parent page's name...in this case About.
$p = Page::getByID(555); #Your page id # $parent = DIR_REL . $p->getCollectionPath(); $parentName = $p->getCollectionName(); echo '<h6>'.$parentName.'</h6>'; $bt_main = BlockType::getByHandle('autonav'); $p = Page::getByID(127); #About Pg. $parent = DIR_REL . $p->getCollectionPath(); $parentName = $p->getCollectionName(); echo '<h6>'.$parentName.'</h6>'; $bt_main = BlockType::getByHandle('autonav'); $bt_main->controller->displayPages = 'custom'; // top, above, below, second_level, third_level, custom (Specify the displayPagesCID below) $bt_main->controller->displayPagesCID = '555'; // <-- Specify the CID of the page named: REPERTOIRE ( Gets the first level of pages under that section ) $bt_main->controller->orderBy = 'display_asc'; $p = Page::getByID(127); #About Pg. $parent = DIR_REL . $p->getCollectionPath();
Viewing 15 lines of 25 lines. View entire code block.
Take a look at this and I'm sure you'll manage this! ;-) Good luck!
http://www.concrete5.org/documentation/introduction/cheat-sheet/...
Nick.