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 Folks,
been a while!
Could someone please remind an old man how to target specific pages in PHP?
Used to go somewhat like: if (G_PATH == 'HOME') {
But had no joy with that.....
Jon
Offline
Have a look at how I did this in Backlight: http://community.theturninggate.net/vie … hp?id=8429
For BL2, the call to page_match needs to be updated as follows:
if ( $this->page_match('/about') ) {
echo '....';
} elseif ( $this->page_match('/contact') ) {
echo '....';
} elseif ( $this->page_match('/galleries/') ) {
echo '....';
} elseif ( $this->page_match('/backlight/search') ) {
echo '....';
}
}
And the example function ttg_main_top( $style, $path ) is now main_top() in BL2.
Last edited by Daniel Leu (2019-03-19 06:56:15)
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Offline
OK,
that worked brilliantly for every page on my site, now how do I get it to target the Home page! I've tried '/home', '/Home', 'home', '/', etc. etc.
What am I missing this time?
Offline
Offline
Just curious, what was the solution?
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Thanks Daniel,
Top man!
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Hi Rod,
hope you are well. Long story, thought I had the Answer, which was using: if ( $this->page_match("/")...
However, this worked on the Home page - and all the others too! Doh! So it wasn't the answer at all.
I found that if I just used - echo $_SERVER['REQUEST_URI']; it showed the url returned for the pages ie. /about/ and /contact/ for the about and contact pages. The home page returned / (backslash). However, using '/' or "/" as the match worked on all pages.
Now I'm back to trying over to find the right escapes to the 'if' statement. using '/contact' only targets the contact page etc. Just doesn't work on the home page.
Please, anyone chip in if you have any suggestions.
Offline
Hi Rod,
hope you are well. Long story, thought I had the Answer, which was using: if ( $this->page_match("/")...
However, this worked on the Home page - and all the others too! Doh! So it wasn't the answer at all.
I found that if I just used - echo $_SERVER['REQUEST_URI']; it showed the url returned for the pages ie. /about/ and /contact/ for the about and contact pages. The home page returned / (backslash). However, using '/' or "/" as the match worked on all pages.
Now I'm back to trying over to find the right escapes to the 'if' statement. using '/contact' only targets the contact page etc. Just doesn't work on the home page.
Please, anyone chip in if you have any suggestions.
Hi Lofty,
Using my page_match function, '/contact' selects all pages that start with '/contact'. This means that with /gallery, all your gallery pages are selected at once. That's how I use it. Since all pages start with '/', you can't use this to select the home page.
To select just the home page you might want to use:
if ($_SERVER["REQUEST_URI"] == "/") {
echo "home page";
}
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
That Definitely works Daniel,
many thanks again for your help
Offline
Just curious, what cool feature are you adding to your site?
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Well,
not new just yet Daniel, doing what I meant to do as advised by Matt some time ago. I have a grid of static links to Galleries and also the latest two Blog Posts. It's been there a while and works well but the html was just in the page copy. So I'm trying to move that code into the php.
Stage 1 completed, thank you. Stage 2 is to get the existing php for the blog posts working. Which I will probably need some pointers on....
Once I have that sorted, I can do other stuff
Offline
There's a sample function in the latest phplugins-pangolin-sample.php file that calls blog posts. It starts at line 561.
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