Is it somehow possible to insert php code to template between the '{' '}'?
Example:
{cms_module module="menumanager" collapse="0" start_element=" "}
I know that this variant doesn`t work, but is there some way to do similarly?
php code in template
Re: php code in template
Create a custom tag. You can enter your php snippet there, and call the {tag} in your template.
Re: php code in template
I found the solution!
I created object and afterwards used the object in content
I must remark that i can`t use tag because using { inside { doesn´t work!
Thanks anyway
I created object and afterwards used the object in content
I must remark that i can`t use tag because using { inside { doesn´t work!
Thanks anyway
Re: php code in template
you are not supposed to use a {tag} inside another tag, or use {} within them. If you really need to do that, most likely you are pushing the boundaries of smarty, so you'd better write your stuff in php.
php code in template
Not sure if this is the correct place in the forum, but I'd like to share this with newbie's (like myself) to cmsmadesimple. I placed the below code into a user defined tag, and then referenced it in my template {the_name_of_my_userdefinedtag}. what it does is take the "name" of a page and determines what HTML gets writen in order to control images, nav on states, etc. once you have the name of the page, the if, elseif and else statement can control enything in the template. it saved me from having 10 versions of the nav (I needed an on state when the user was on a particular page, and to insert some javascript on the homepage only). Being able to do this saved me a ton of time.
-----------------------------------------------------------
global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];
if ($thispage == the_name_of_one_of_your_pages) echo "something_you'd_like_written_to_this_page";
elseif ($thispage == the_name_of_another_one_of_your_pages) echo "something_else_you'd_like_written_to_this_page";
else echo "something_you'd_like_written_as_your_default";
-----------------------------------------------------------
global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];
if ($thispage == the_name_of_one_of_your_pages) echo "something_you'd_like_written_to_this_page";
elseif ($thispage == the_name_of_another_one_of_your_pages) echo "something_else_you'd_like_written_to_this_page";
else echo "something_you'd_like_written_as_your_default";
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: php code in template
Very cool Dan, thanks!!
I think it provides us with a perfect example of how to use user defined tags.
I think it provides us with a perfect example of how to use user defined tags.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: php code in template
Yes, that reminds me, I should try to give more encouragement en compliments. If only I knew how to do that easy...
Here's one try: thanks Calguy for reminding me.
Here's another: Thanks Dan, that is usefull code. Maybe one could use that too to support icons in the naviagtion?
(hmm... no... probably not like that. But volunteers are welcome to show how they used a customtag(or smarty?) to support pretty pictures in their menu.
Here's one try: thanks Calguy for reminding me.
Here's another: Thanks Dan, that is usefull code. Maybe one could use that too to support icons in the naviagtion?
(hmm... no... probably not like that. But volunteers are welcome to show how they used a customtag(or smarty?) to support pretty pictures in their menu.
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: php code in template
Here's my custom menu template that I use in the Menu Manager. It uses the Silk Iconsjelle wrote: Maybe one could use that too to support icons in the naviagtion?
(hmm... no... probably not like that. But volunteers are welcome to show how they used a customtag(or smarty?) to support pretty pictures in their menu.
Code: Select all
{if $count > 0}
<ul class="menu_horiz">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->index == 0}
{assign var="icon" value="house"}
{elseif $node->haschildren == true }
{assign var="icon" value="folder"}
{elseif $node->haschildren == false }
{assign var="icon" value="page"}
{/if}
{if $node->current == true}
<li style="list-style-image: url('/images/icons/{$icon}_go.png') ">{$node->menutext}
{else}
<li style="list-style-image: url('/images/icons/{$icon}.png') "><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
{/if}
{/foreach}
{repeat string="</li></ul>" times=$node->depth-2}</li>
</ul>
{/if}
[attachment deleted by admin]
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: php code in template
If we follow example above, then i have another question.
I enter UDT name into template and the source of tag is down below.
My web page prints out:
{cms_module module=FrontEndUsers login='true' lang='et_EE' }
How can i do that i see login box instead of a tag?
tag source:
global $gCms;
$thispage = '';
$thispage = $gCms->variables['hl'];
if ($thispage == 'ee') echo "{cms_module module=FrontEndUsers login='true' lang='et_EE' }";
elseif ($thispage == 'en') echo "{cms_module module=FrontEndUsers login='true' lang='en_US'}";
else echo "{cms_module module=FrontEndUsers login='true' lang='et_EE'}";
Thanks in advance
I enter UDT name into template and the source of tag is down below.
My web page prints out:
{cms_module module=FrontEndUsers login='true' lang='et_EE' }
How can i do that i see login box instead of a tag?
tag source:
global $gCms;
$thispage = '';
$thispage = $gCms->variables['hl'];
if ($thispage == 'ee') echo "{cms_module module=FrontEndUsers login='true' lang='et_EE' }";
elseif ($thispage == 'en') echo "{cms_module module=FrontEndUsers login='true' lang='en_US'}";
else echo "{cms_module module=FrontEndUsers login='true' lang='et_EE'}";
Thanks in advance