Page 1 of 1
use php in template?
Posted: Sat Jul 23, 2005 12:16 pm
by angels
how can i use php in the template?
Re: use php in template?
Posted: Tue Jul 26, 2005 6:52 pm
by nils73
usually you can use php in smarty by using {php} echo "Hello World"; {/php} ... but as Patricia already pointed out, User Tags are much better here.
Regards,
Nils
use php in template?
Posted: Wed Jan 25, 2006 10:38 pm
by dan
i'm trying to print the variable name to the template each time a user passes the name through a url string--to display a diifferent header image for each page. i've created a user friendly tag called {graphic_header} and placed it into the template. the php code i'm using is this (without tags. problem is, the variable name isn't printing to the page. any suggestions/help would be appreciated. thanks!
echo "$page";
Re: use php in template?
Posted: Thu Jan 26, 2006 3:50 pm
by nils73
I use this one on my pages:
global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];
Simply put this into your user-defined tag and it should work ...
Regards,
Nils
Re: use php in template?
Posted: Thu Jan 26, 2006 9:09 pm
by dan
pardon my stupidity. i pasted your code into my userdef tag. do i change [page_name] to something else. in my case $thispage is $page. doesnt seem to work. thanks anyway.
Re: use php in template?
Posted: Fri Jan 27, 2006 11:06 am
by nils73
I am not quite sure whether
$page is already taken by CMSMS ... I just created a user-defined tag called "labelme" and inserted the following code:
Code: Select all
global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];
echo $thispage;
Then you simply insert the following code (just for testing) into your template(s) body-element:
If you now open any webpage, it should work. At least it does on my installation of CMSMS - tested only a few minutes ago. Good luck.
Regards,
Nils
Re: use php in template?
Posted: Mon Jan 30, 2006 3:35 pm
by dan
that worked. thanks Nils!!!!
Re: use php in template?
Posted: Mon Jan 30, 2006 4:47 pm
by nils73
Glad to hear that, dan. Good luck!