I'm trying to call up one of two menus from my index.tpl using smarty and php. The chosen menu will depend upon which page the user is linking from. Is this possible? I know I can't put the php directly into the tpl, so here is the code I am currently using which isn't doing what I want.
{if $ref == 'http://www.FIRST OF THREE ADDRESSES.html'}
{if $ref == 'http://www.SECOND OF THREE ADDRESSES.html'}
{if $ref == 'http://www.THIRD OF THREE ADDRESSES.html'}
//menu if the user is coming from 1 of 3 addresses
{else}
//menu for someone coming from anywhere else
{/if}
What I would like to do is have the code discover if the user is linking to the page from 1 of 3 different pages. The user will only have access to the page from any of those 3 pages. So when the user comes to my page with the index.tpl, it will pop up the correct menu. If it is not from 1 of the 3 pages, it will run the {else} menu.
Sorry for being confusing. It just seems to be the only way for the time being. Can this be done??? If so how?
I tried using the method that is described at http://www.s9y.org/78.html under the subtitle "Inserting you own Stuff", but that does not seem to be working either. I made a php file called config.inc.php that holds the php I want. The file lives in the same directory as the index.tpl file. Then I am using Smarty's method of calling up a file which is:
{if $ref == 'http://www.FIRST OF THREE ADDRESSES.html' OR
$ref == 'http://www.SECOND OF THREE ADDRESSES.html' OR
$ref == 'http://www.THIRD OF THREE ADDRESSES.html'}
...
{/if}
Your way of IF nesting would need also three {/if} closing statements.
PHP includes in Smarty are by default not enabled. Which is why in the documentation we refer to the template'S config.inc.php where you need to put wrapping code. But you shouldn't be needing this specific method, because your described way should work fine.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
I'm still not getting any communication going on between the config.inc.php and the index.tpl.
The file that I am putting the Smarty markup in is /templates/default/index.tpl.
Now where exactly do I put the config.inc.php file?
From what documentation I read, the file needs to be created and then put into the same directory as the tpl. Is this correct? I used the same php as in my first post to go into my config.inc.php file.
Just not getting a response like I should with that setup.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Thanks for your continued help! I put the following code in my config.inc.php and it is appently not being read, because it didn't make any change in the blog (still loaded fine).
Why is this happening? Is there anywhere else I could place the Php to communicate with the tpl?
Also, My theme is set to s9Y Orange. That is where I make adjustments to my CSS. Then I am altering the default theme index.tpl, that is where the config.inc.php file resides. I have tried putting it in my s9Y Orange theme file, and that doesn't do anything either. Is this setup somehow causeing the file not to be parsed?
You didn't mention you weren't using the default theme. *g*
So, I guess I need to be more precise: The config.inc.php needs to be within the template directory of the template you are using.
If a .tpl file is not contained iny our active template directory, it is fetched frm the "default" directory - but the config.inc.php is always searched in your active template directory only.
If you are altering a .tpl file, NEVER alter it in the default directory. Always copy it over into the theme directory of the theme you are modifying, that's safer.
(Some clarifications are in the templating section of s9y.org...)
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
I remember reading about that during my first Serendipity install. In fact, I even altered my theme tpl's in that fashion. Then I got so many different Serendipity experiments going on...I figured I'd just as well adjust the default, not spending any extra time moving the files around. Then if I found that I needed my original default.tpl back, I would just pull it out of another serendipty folder.
I LEARNED MY LESSON
It's working great now, just as expected. Thanks again for the help, I really appreciate it.
I hope you'll continue to have fun with Serendipity!
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/