Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

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

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
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
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#2 2019-12-20 10:17:45

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

Re: Page specific PHP code


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

Board footer

Powered by FluxBB