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-10-08 03:07:08

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Use of PHP Includes Viable?

A Non-Backlight part of my website has pages where I use what's known as "PHP Include" which is a line of code pointing to content that can be integrated across more than one page, such as a table with dates, and such.

Instead of having to modify several documents with the same table content, from page to page — which can be very time consuming, let alone leaving a huge potential to create errors, omissions, and conflicting information — it's great to modify a single "PHP Include" document that updates all pages that point to it.

The line of code I use looks something like this:
<?php include("pho105_announce.php"); ?>

I'm just curious to ask if Backlight supports anything similar that I can use in more than one of my backlight/custom/phplugins documents to use the same tabled content? I tried integrating that line of code noted above, but no luck in generating anything in a web browser, even by using various iterations of "../../" in the doc name.

Thanks for giving this any thought...
Don


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#2 2018-10-08 03:42:28

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

Re: Use of PHP Includes Viable?

have you tried using an absolute url to the file?


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 2018-10-08 13:07:20

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

Re: Use of PHP Includes Viable?

I did a little test and it works for me. Did you get any errors? I put my test file in /backlight/custom/phplugins and tried with following two versions of using include:

// v1
include("dlp_common.php"); 

//v2
include(realpath(BACKLIGHT_HOOK) . "/custom/phplugins/dlp_common.php"); 

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

Offline

#4 2018-10-17 12:23:58

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Hi Rod & Daniel,
Sorry for the late reply. Been pre-occupied with other projects.

Unfortunately none of those solutions work on my end, but then, I might very well be placing your suggested code solutions in the wrong place, or the wrong way. I'm clearly missing something to understand how to integrate it.

Thanks very much for giving this your time & effort.
I'm moving on to some other aspects of the site build.
Don


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#5 2018-10-22 04:15:12

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Use of PHP Includes Viable?

DonWa2,

You should be able to use any valid PHP in PHPlugins files. If you're attempting to add PHP to the page content through Backlight's admin, that's not going to work.


Matt

The Turning Gate, http://theturninggate.net

Offline

#6 2018-10-22 04:49:27

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

Re: Use of PHP Includes Viable?

Matthew wrote:

DonWa2,

You should be able to use any valid PHP in PHPlugins files. If you're attempting to add PHP to the page content through Backlight's admin, that's not going to work.

Didn't think of that... most likely that's the culprit.


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

Offline

#7 2018-11-10 12:10:02

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Thanks all for the replies on this...

@Daniel
I am indeed trying to use *includes* via the phplugins folder [not via Backlight admin]. I created a designated php file with content, and uploaded that doc inside of the phplugins folder, then pointed the suggested code in the document I want it to appear in.

Tried this:
include("winter_dates.php");

and this iteration:
<?php include("winter_dates.php"); ?>

I tried the more elaborate *//v2* line of code as well, with no luck.

I got nothing to appear.
Sorry for my confusion and misunderstanding.
Don


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#8 2018-11-10 14:45:41

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

Re: Use of PHP Includes Viable?

Just curious, do you add the include code to the ttg_head hook?


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#9 2018-11-10 15:51:31

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

Re: Use of PHP Includes Viable?

This is what I'm using. As you see, I tried with relative and absolute file paths.

<?php
/*
 *	TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
...
 */

function user_load($style, $path) {...}

if (defined('BACKLIGHT_HOOK')) {...}

// v1
include("dlp_common.php"); 

// v2
include(realpath(BACKLIGHT_HOOK) . "/custom/phplugins/dlp_common.php"); 

class PHPlugins extends APHPlugins {...}
?>

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

Offline

#10 2018-11-10 15:53:48

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Thanks Rod,
I haven't added the include code in the tag_head hook.
I didn't imagine it needing to work that way, but then it's times like this when I feel as though I'm in way over my head in this.


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#11 2018-11-10 16:18:43

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Thanks, Daniel... I'll give that a try.


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#12 2018-11-12 13:33:17

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Sorry to say that I'm not finding any success with this.

Although this method works fine outside of Backlight, without additional coding elsewhere...
<?php include("winter_dates.php"); ?>
...this doesn't work in Backlight.

...inside of Backlight, even with the addition of the code to the TTG Head Hook noted previously, it doesn't produce data from the target file.

I'm wondering if PHP settings on the server need to be tweaked?
Don


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

#13 2018-11-13 14:03:01

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Use of PHP Includes Viable?

Syntax.

function main_top() {
  include 'someFile.php';
  return false;
}

Matt

The Turning Gate, http://theturninggate.net

Offline

#14 2018-11-21 14:12:35

DonWa2
Member
From: Ann Arbor, Michigan USA
Registered: 2015-11-03
Posts: 69
Website

Re: Use of PHP Includes Viable?

Hi Matt,
This works, thanks. I've used this include function in a footer with great satisfaction.
It appears that an include file can only be used within a designated, function _HOOK_() {...}

I was hoping to re-use a small table residing inside a grid column, from one page to the next with syntax nested after of the aforementioned HOOK. For instance...

<div class="col_3"><?php include("pho105_announce.php"); ?>
</div>

Even if this "announce.php file" resides inside the phplugins folder, it still doesn't work. I speculate that the Backlight eco-system is not conducive to seeing this the same, as it works with bootstrap.

I'm no expert at this stuff [and I apologize for my ignorance], yet I find it's interesting to touch some of the walls once inside Backlight. Keep up the great product development!
Thanks again for your insights.
Don


Quatrain ƒotographic, LLC
…seeing, thinking, teaching. Visual Poetry.
https://quatrainfotographic.com

Offline

Board footer

Powered by FluxBB