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.
It would help me a lot if I could call self-defined functions (that are in PHPlugins.php) from within the Markdown text I use in a template.
Let's say i have, in PHPlugins.php, this function:
function MyFunction()
{
echo "Hi, MyFunction() has been called";
}
and I have a Markdown text in my Lightroom template for Gallery or Stage, like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus semper ipsum nibh.
<?php
echo "now calling MyFunction()<br>";
MyFunction();
echo "MyFunction() has been called<br>";
?/
This code doesn't work, because MyFunction() can't be found.
I'm wondering if there is a way to make it found!
Thanks!!!
Harald
Harald Joergens ARPS
Harald Joergens Photography
Nutfield, Surrey, UK
Offline
I was able to get it to work in an exported and uploaded gallery. Haven't tried it yet via Publisher.
the code you posted for use in the Page Copy (md) field isn't closed properly
It should be closed with ?> not ?/
also, you don't need that final echo unless you want something like this on the page:
Hi, MyFunction() has been calledMyFunction() has been called
try this instead
<?php
echo "now calling MyFunction()<br>";
MyFunction();?>
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 don't think it will work via Publisher. Unless the Markdown library parses text for PHP, this should be output as-is into the web page.
Offline
Looks like it works if the php is part of the gallery template's page copy and if that page copy is used in the album.
You can see it here:
http://ce4.barbeephoto.com/galleries/test2/
The main copy on the left was entered in the album's Page Copy field. The sidebar copy on the right comes from the template.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Looks like it works if the php is part of the gallery template's page copy and if that page copy is used in the album.
You can see it here:
http://ce4.barbeephoto.com/galleries/test2/
The main copy on the left was entered in the album's Page Copy field. The sidebar copy on the right comes from the template.
Hi Rod,
That's excellent, thanks for the time you spent finding all this out!
It works very well indeed, in Publisher, when the PHP code is part of the template, it doesn't work at all (as far as I can see) if the code is part of the text in the album definition.
Using PHP in a template adds a lot of flexibility, in CE3 I had used PHPlugins to get the behaviour I wanted in a gallery page, with this, in CE4, I can have different templates doing different things. Brilliant!
Thanks again
Harald
Harald Joergens ARPS
Harald Joergens Photography
Nutfield, Surrey, UK
Offline