Adding a Back Button to Concrete5 Template

By Jeff Denton Aug 25, 2011

I've been doing a couple of projects with the Concrete5 CMS recently and it's a joy to use! The template I implemented was designed for the iPad (more on that in another post) so one of the UI elements I wanted to include in the template was a Back button in the header. This would provide an easy way for the user to navigate out of sub-pages within the site. 

I sought a little guidance at first and found some good advice in adding breadcrumb navigation in a Concrete5 site.

First of all, add the following lines at the top of your template default.php file right below the defined() function:

$page = Page::getByID($c->getCollectionParentID());
$parent_url = View::URL($page->getCollectionPath());
$nh=Loader::helper('navigation');
$breadcrumb = $nh->getTrailToCollection($c);

Then add the following lines in the place where you want your back button to appear.

if (count($breadcrumb)>0) {
echo 'Back';
}

This code should show a back button whenever you navigate past the home page of the site.

Add Your Comments