Hi all,
I'm giving G2 a go, but have run in to a problem that's stumped me. Here's my question. I am running WordPress blog software and have created a nice header for it (header.php). I would like to include this file above the G2 header. I've poked around in the global.tpl file, but don't know enough about how to go about doing this. Can I insert a php include call somewhere, or maybe a SSI call? With G1, editing the wrap header file was fairly simple :-? I don't know enough about smarty or the new templating system.
I should also note that the header.php file resides 'outside' of the Gallery2 directory and I'd prefer to keep it that way (as opposed to having duplicate files, etc.)
Any help or suggestions would be greatly appreciated. Thanks in advance!
Posts: 8601
to put php into a smarty template put {php} ... {/php} around it.
Posts: 19
Thanks for the reply mindless. When I try that however, nothing loads at all. I placed the code {php}include file="http://www.myserver.com/wp-content/header.php"{/php} into the global.tpl file, trying it in various locations, but got the same result.
Posts: 7994
Everything inside the {php} tags must be valid php! Try this:
Posts: 238
Looks like you're trying an apache server-side include instead of a php include. Try this instead {php}include "http://www.myserver.com/wp-content/header.php"{/php}. You may need to wrap the quoted url with parens.
Posts: 19
Bharat, thanks for the reply. I gave that a try, but it still doesn't load the file. Am I trying to modify the correct file?...global.tpl.local ??
Maybe this isn't possible to do?
Posts: 7994
Oops, sorry I accidentally replied too quickly and gave you a bad example.
Don't use global.tpl.local -- that's the old system and is on the way out. Instead create a new directory and copy global.tpl into it, then modify the copy:
Then inside the global.tpl file put:
See how we're using the path on the filesystem to WordPress's header.php, not a url.
Posts: 19
bharat, I've given that a try, but still no joy. I created the directory "local" inside the templates directory and moved the global.tpl copy in there to modify as you suggested, renamed to global.tpl. I tried using both a URL in the code and the absolute path, which *should* be:
{php}include("../wp-content/themes/arzel_kt2/header.php");{/php}
and that doesn't work either Do I need to chmod the "local" directory maybe? Or is my ablsoute path incorrect? Not sure what I'm still doing incorrectly. *sigh*
Thanks again for your help. It's really an honor to receive a reply from "the man" I'd sure love to get this figured out.
Posts: 7994
I need to know more than "it doesn't work". How does it fail? There are lots of reasons why it might not work so the more information you provide, the faster we can narrow it down. Start by verifying that the local override is actually working. Try making a small, visible change to the file. If that's working then try experimenting with the {php} tag. You should avoid using relative paths in your include since you can't be totally sure what the base path. It's better to use a full path instead.
We all do our best.. we'll help you sort this out.
Posts: 19
Sorry for being too vague. Essentially, what I meant was, nothing had changed appearance wise. The G2 pages still looked "stock".
I then modified the local file with something that should have show up as you suggest, but that change did not appear. So the local directory and file are not loading. So I went back to using the global.tpl file in it's default location, and my "test" text change does show up correctly, as expected.
Next, I changed the path in the php code inside the global.tpl file to "/Library/WebServer/Documents/wp-content...etc." (I assume that's what you mean by "full" path. Again, my test text shows up in the header area as expected, but the header.php file still fails to load or appear.
Thanks again.
Posts: 3236
Maybe you just need to clear out some of the cached content in /g2data? Don't go deleting willy nilly, but someone else who knows will probably tell ya what you should look into nuking
Posts: 32509
dunno if it's a cache issue, but you can clear the cache here:
http://www.pixxelated.com/gallery2/lib/tools/test/
note: clearing the cache doesn't harm your gallery / your data. but resetting / reinitializing, ... will delete all your g2 data / users.
Posts: 19
Thanks for all the replies and suggestions. However, I've decided (for now at least) to try another route, by removing the links in the banner and placing them underneath the banner. I haven't tested things with different platforms and browsers, but it looks OK to me using Apple's Safari and Firefox. IE Mac does some strange things, but I don't care about that much.
Cheers and thank you again.
Posts: 35
force a php error.. then you will see the full server path.. then edit it to point to your header.php file
/usr/www.whatever.com/home/htdocs/includes/header.php
Posts: 32509
astralbaby, lol, nice method.
Posts: 14
This post is old, but I am trying to do the exact same thing with no luck:
But this isn't working. I am using the Matrix theme and modifying the theme.tpl
Anyone know how I can include the header and footer? Thanks.
Posts: 8601
enter a filesystem path to include (like /home/you/public_html/head.php) not a URL