Jordan Lev Logo Jordan Lev's Concrete5 Tips

How to make things work when building a Concrete5 website.

Hard-Coded Autonav Options

| Comments

It is often useful to “hard-code” the autonav block directly into your templates, so that the user doesn’t have to configure them and you can guarantee that they’ll always appear on every page of the site. Unfortunately, figuring out what the various options are and what they do can be very confusing. Below I’ve documented all of the available options, along with the corresponding explanations from the autonav block edit window.

Option Corresponds To… Value Corresponds To…
orderBy Pages Should Appear display_asc in their sitemap order.
  chrono_desc with the most recent first.
  chrono_asc with the earliest first.
  alpha_asc in alphabetical order.
  alpha_desc in reverse alphabetical order.
  display_desc in reverse sitemap order.

displayUnavailablePages Display pages to users even when those users cannot access those pages. 0 No (unchecked)
  1 Yes (checked)

displayPages Display Pages top at the top level.
  second_level at the second level.
  third_level at the third level.
  above at the level above.
  current at the current level.
  below At the level below.
  custom Beneath a particular page

displayPagesCID “Select Page”
(only applies if displayPages == ‘custom’)
# (Collection ID number of parent page)

displaySubPages Sub Pages to Display none None
  relevant Relevant sub pages.
  relevant_breadcrumb Display breadcrumb trail.
  all Display all.

displaySubPageLevels Sub-Page Levels
(only applies if displaySubPages != ‘none’)
enough Display sub pages to current.
  enough_plus1 Display sub pages to current +1.
  all Display all.
  custom Display a custom amount.

Common Examples

Single-Level Dropdown Menu (1 level of dropdown)

1
2
3
4
5
6
7
8
9
<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>

Header Menu (no dropdown)

1
2
3
4
5
6
7
<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'none';
$nav->render('templates/header_menu');
?>

Breadcrumb Trail

1
2
3
4
5
6
7
8
<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'relevant_breadcrumb';
$nav->controller->displaySubPageLevels = 'enough';
$nav->render('templates/breadcrumb');
?>

Comments