Display navigation area

Permalink
Hello
I would like to be able to put the area of the site as a title.

For example if the top level has "Home - News - Contact" and you were to click on "News" I would like to add the word "News" as a heading. Then if there was a level down from News e.g:
News - news item 1 - news item 2 - news item 3

I would still like to show the title "News" on all the sub pages.

is there away of doing this I've been looking around for quite a while now and can find one.

thanks for any help

Jonnym

 
wagdi replied on at Permalink Reply
wagdi
Go to Dashboard>> pages and themes>> Pagetypes>> Default

Pick the page type you wish to edit.. Im guessing its a blog page type.

You could just add the title 'News' using a normal content block and it will now appear every time you add that page type. :)

Hope that helps.
jonnym replied on at Permalink Reply
Sorry I need to be clearer.

I need the heading to reflect the area on all the nav areas.

So for example:
"Home - News - Products- About us - Contact"

So if a page was added under About us it would require the heading About us. If the page was a sub-sub page under About us it would also have the heading of About us.

If a page was added under News it would require the heading News. If the page was a sub-sub page under News it would also have the heading of News.

The Page types will be used under many navigation areas so it needs to be taken from the Database.

Thanks for any help

Jonnym
jordanlev replied on at Permalink Reply
jordanlev
You should be able to pull the parent section out of the current page's path, like so:
<?php
$sections = explode('/', $c->getCollectionPath());
$top_section_path = '/' . $sections[1];
$top_section_title = Page::getByPath($top_section_path)->getCollectionName();
?>
...
<h1><?php echo $top_section_title; ?></h1>
jonnym replied on at Permalink Reply
I can seem to get the code to display anything.

I've added it to a template page and uploaded it and its not showing anything? Any thoughts?

thanks jonnym
jordanlev replied on at Permalink Reply
jordanlev
Can you post your template code so I can see?
jonnym replied on at Permalink Reply
Find code below

I have been working on and haven't full error checked it but it should be OK


<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>      
<div id="maincontainer">
  <div id="content">  
 <div id="subnav">
      <div id="subnav_links">
      <h2>test<?php
$sections = explode('/', $c->getCollectionPath());
$top_section_path = '/' . $sections[1];
$top_section_title = Page::getByPath($top_section_path)->getCollectionName();
?></h2>
        <?php 
         $as = new Area('Sidebar');
         $as->display($c);
jonnym replied on at Permalink Reply
I must be tired or incredibly stupid or just haven't read your post or the code properly. Its working now I've implemented it properly!

thanks again Jonnym
TheRealSean replied on at Permalink Reply
TheRealSean
I created a block that will give you the choice to display a Page Title its Parent Page or a custom page, its not a submitted block so probably has loads of messy code in there. It uses a tick box to display each level and a custom input to display that text. I will upload it tomorrow when at work.

I achieved it using the getParentID() function
$page = Page::getCurrentPage();
$parentPage = Page::getByID($page->getParentID());
$parentPage_title = $parentPage->getCollectionName();
//you could go a step further
$grandParentPage = Page::getByID($parentPage->getParentID());
jonnym replied on at Permalink Reply
Any chance of that block TheRealSean?

thanks in advance

Jonnym
jonnym replied on at Permalink Reply
Great thanks
I will try to implement them today


thanks for your help
jonnym
GrafFoto replied on at Permalink Reply
Hello.

Thanks for this perfect code - that's exactly what I am lookong for!!!!
But did anybody know what I have to do if I need the result as a link to the shown site?
GrafFoto replied on at Permalink Reply
Okay, I found the answer by myself. If you want the H1 as a link you have to use this code:

<?php
$sections = explode('/', $c->getCollectionPath());
$top_section_path = '/' . $sections[1];
$top_section_title = Page::getByPath($top_section_path)->getCollectionName();
?>
<h1><?php echo "<a href=\"$top_section_path\">$top_section_title</a>"; ?></h1>