Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2018-02-03 16:12:05

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 882
Website

Page specific PHP code

With CE4, G_STYLE could be used to insert page specific PHP code using phplugins. With Backlight, this is no longer possible. But there is a simple way around that:

First I need a simple helper function 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;
   }
}

And then I use this function to match specific pages:

function ttg_main_top( $style, $path ){
	if ( page_match('/about') ) {
		echo '....';
	} elseif ( page_match('/contact') ) {
		echo '....';
	} elseif ( page_match('/galleries/') ) {
		echo '....';
	} elseif ( page_match('/backlight/search') ) {
		echo '....';
	}
}

As you can see, this can be used to select a single page or several pages on a lower level (eg, galleries) and then introduce page specific code. On my site, I use this add breadcrumbs to my standard pages.

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

Board footer

Powered by FluxBB