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.
You are not logged in.
Pages: 1
Hi,
I'm migrating my running CE4 website to backlight (1.2.3r4).
What I wish do have is a hook triggered only when a specific page is called.
Is there a php variable like $page or a env variable containing the path or the identifier?
in the CE4 environment I did it like this for example for the standard 'Info' page:
function ttg_block_bottom( $style, $path ) {
if (G_STYLE == 'CE4-PAGES-INFO') {
echo '.....'
}
}
This runs well although I never explored the possibility to trigger it beyound a standard page identifier.
Hope you have an idea!
Regards,
Jürgen
Offline
You could use php to determine what page is being displayed and if it matches, say /info.php, then run the function.
From this page, here's an idea:
function ttg_main_bottom( $style, $path ) {
$info = "/info.php";
$info = $_SERVER['REQUEST_URI'];
if($homepage==$currentpage) {
echo '...........';
return true; //or false
}
}
(I'm no php expert, not even close. Not even in the ballpark. So this may need to be refined. Or it might break your site. It should be exciting!)
But there may also be a hook for that, Matt will have to chime in.
Another option is to create a separate phplugins file for the purpose and activate it in a separate page template for the purpose.
So if you want something inserted in your Info page, use a separate page template that uses the specific phplugins file. Might not be as elegant, but it should work.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I use a simple function to match a specific page:
function page_match($gallery) {
if (substr($_SERVER["REQUEST_URI"], 0, strlen($gallery)) == $gallery) {
return 1;
} else {
return 0;
}
}
And then I used like this
function ttg_main_top( $style, $path ){
// Add breadcrumbs to non-gallery pages
if ( page_match('/about.php') ) {
ttg_crumb('About');
} elseif ( page_match('/contact.php') ) {
ttg_crumb('Contact');
} elseif ( page_match('/backlight/search') ) {
ttg_crumb('Photo Search');
}
}
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Thank you Rod for your suggestion to use separate scripts for each page, I forgot to mention it's my current workaround but I have to maintain a bunch of templates whitch hold 99,9% of the same configuration.
Daniel, I will give your solution a try, thank you very much!
Offline
I try to avoid using separate phplugins or css files if I can. Just gets too much of a pain after a while. I also try to not use too many page templates as well since that means any design changes need to be made in all templates.
Daniel's solution is probably the best since we already know it works!
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Pages: 1