use php in template? Topic is solved
Re: use php in template?
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
Regards,
Nils
use php in template?
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";
echo "$page";
Re: use php in template?
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
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?
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?
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:
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
Code: Select all
global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];
echo $thispage;
Code: Select all
<p>My page_name is: {labelme}</p>
Regards,
Nils
Re: use php in template?
Glad to hear that, dan. Good luck!