Include AutoNav in Page Template

Permalink
Hi all,

Forgive me if this has already been answered. I searched the forums and couldn't find a solution.

I've just recently started using concrete and I love it. However, I've having a bit of a challenge. Instead of recreating the autonav on every page, I'd like to use php to include it (or the php equivalent) in my template. That way, every page that uses the template will inherit the navigation.

Here are the settings I'm using for the autonav, although I would prefer to go a step further (see below).

Pages Should Appear > in their sitemap order.
Display Pages > At the level below.
Subpages to display > Relevant subpages.
Subpage Level > Display subpages to current.

Ideally, I would like for the autonav to display any relevant subpages for the current page. However, if there are no subpages, I'd like for it to display the pages on the current level. For example, suppose you have the following directory structure.

<ul>
<li>About</li>
<ul>
<li>About subpage 1</li>
<li>About subpage 2<li>
</ul>
</ul>

On the "About" page, the autonav should display the current subpages (sub1 and sub2), however on sub1, the autonav should display "sub 1" and "sub 2" since there are no subpages or children for these.

Any help would be greatly appreciated.

 
jaredquinn replied on at Permalink Reply
jaredquinn
Yeah, this one has been answered already, but the easiest way I find to include a block like Nav everywhere:

$dp = $c->getCollectionID() == 1 ? $c : Page::getByID(1,'ACTIVE');
$a = new Area('Header Nav');
$a->display($dp);


This retrieves the block from Collection (page) #1 (Home), and uses it on all pages, however, it's only editable on the page it belongs to.

The above code is from the elements/header.php from a theme I'm using on http://icebergs.oneforall.com.au...

You may need some custom tweaking or template design for the block to modify the settings based on where you're at.

cheers,
jared
LucasAnderson replied on at Permalink Best Answer Reply
LucasAnderson
You may just need Page Defaults. These set a block you create to show up automatically when new pages are created with that page type.

Here's some more information:

http://www.concrete5.org/community/forums/usage/handy-trick-with-pa...

Look at the first reply on this post:

http://www.concrete5.org/community/forums/customizing_c5/including-...