Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2018-02-03 16:24:44

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,013
Website

Breadcrumbs on standard pages

Backlight provides the option to use breadcrumbs on all gallery pages to simplify navigation. I like to have a common look and feel of my site and prever to have breadcrumbs on all pages. Thanks to phplugins, this is something that can easily be done.

First I use some helper functions to keep my code clear and legible:

function page_match($gallery) {
   if (substr($_SERVER["REQUEST_URI"], 0, strlen($gallery)) == $gallery) {
      return 1;
   }  else {
      return 0;
   }
}

function ttg_crumb( $page_name ) {
	echo '<ul class="breadcrumbs"><li class="fa_pseudo" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/" itemprop="url"><span itemprop="title">Home</span></a></li><li class="fa_pseudo" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">'. $page_name .'</span></li></ul>';
}

Breadcrumbs are located at the top of the 'main' section. So I use ttg_main_top to insert them:

function ttg_main_top( $style, $path ){
	// Add breadcrumbs to non-gallery pages
	if ( page_match('/about') ) {
		ttg_crumb('About');
	} elseif ( page_match('/contact') ) {
		ttg_crumb('Contact');
	} elseif ( page_match('/backlight/search') ) {
		ttg_crumb('Search');
	} elseif ( page_match('/xxxx') ) {
		ttg_crumb('Xxxx');
	}
}

If you have other pages on your site, just add them in another 'elseif' branch. All this code belongs into your custom phplugins file.

You find a bit more about phplugins in the documentation at http://backlight.theturninggate.net/doc … _phplugins.


Daniel Leu | Photography   
DanielLeu.com

Offline

#2 2018-09-18 02:46:02

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,013
Website

Re: Breadcrumbs on standard pages

This would be the corresponding code for Backlight 2:

function ttg_crumb( $page_name ) {
	echo '<ul class="breadcrumbs"><li class="fa_pseudo" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/" itemprop="url"><span itemprop="title">Home</span></a></li><li class="fa_pseudo" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">'. $page_name .'</span></li></ul>';
}

function main_top(){
	// Add breadcrumbs to non-gallery pages
	if (strtolower($this->slug) == 'about') {
		$this->ttg_crumb('About');
	} else if (strtolower($this->slug) == 'contact') {
		$this->ttg_crumb('Contact');
	} else if (strtolower($this->slug) == 'search') {
		$this->ttg_crumb('Search');
	} else if (strtolower($this->slug) == 'xxxx') {
		$this->ttg_crumb('Xxxx');
	}
}

Daniel Leu | Photography   
DanielLeu.com

Offline

Board footer

Powered by FluxBB