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 2016-01-09 01:15:20

HaraldJ
Member
From: Surrey, United Kingdom
Registered: 2012-10-10
Posts: 77
Website

Can I call a function inside PHPlugins from a gallery?

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

#2 2016-01-09 01:58:57

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can I call a function inside PHPlugins from a gallery?

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

#3 2016-01-09 05:30:57

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Can I call a function inside PHPlugins from a gallery?

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

#4 2016-01-09 06:16:49

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can I call a function inside PHPlugins from a gallery?

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

#5 2016-01-10 01:46:36

HaraldJ
Member
From: Surrey, United Kingdom
Registered: 2012-10-10
Posts: 77
Website

Re: Can I call a function inside PHPlugins from a gallery?

rod barbee wrote:

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

Board footer

Powered by FluxBB