Page 1 of 1
Integrating PHP into menu templates
Posted: Wed Aug 29, 2007 4:28 pm
by ahmednuaman
Hey,
I've been doing some reading up on Smarty tags and I understand that you can use them like:
{php} some php code {/php}
However, how can I take {$node->accesskey} and feed that var into a php smarty tag?
Re: Integrating PHP into menu templates
Posted: Wed Aug 29, 2007 8:14 pm
by Nullig
it's probably better to use a UDT, which can have params passed to it.
Read about them here:
http://wiki.cmsmadesimple.org/index.php ... fined_Tags
Nullig
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 12:12 am
by calguy1000
check out smarty.php.net/manual/en
there's a function in smarty called get_template_vars
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 10:09 am
by ahmednuaman
calguy1000 wrote:
check out smarty.php.net/manual/en; there's a function in smarty called get_template_vars
Cool, had a read of that, but how would I use it? $node->get_template_vars?
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 11:14 am
by alby
ahmednuaman wrote:
calguy1000 wrote:
check out smarty.php.net/manual/en; there's a function in smarty called get_template_vars
Cool, had a read of that, but how would I use it? $node->get_template_vars?
No, use:
{get_template_vars}
This stamp all note smarty variables.
If there are Array variables, you can check with:
{$your_array|print_r}
Alby
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 2:07 pm
by calguy1000
in php code you would:
Code: Select all
global $gCms;
$smarty =& $gCms->GetSmarty();
$myvar = $smarty->get_template_vars('myvar');
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 2:16 pm
by ahmednuaman
Ok, what if the var is:

Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 2:23 pm
by calguy1000
$node = $smarty->get_template_vars('node');
print_r( $node );
Re: Integrating PHP into menu templates
Posted: Thu Aug 30, 2007 2:42 pm
by ahmednuaman
Cool thanks!
Re: Integrating PHP into menu templates
Posted: Thu Sep 06, 2007 2:06 am
by xnau
This is all very helpful to me right now--I'm creating a user-defined tag...but there's something maddengly basic about getting to the values of the array I'm not getting here. I'm using this test code:
Code: Select all
$node = $smarty->get_template_vars('node');
print_r($node);
echo $node['menutext'];
I get the array dump, but I get nothing for the array value after that. I've looked into the php syntax and it all seems right...so could someone clue me on what I'm doing wrong

thanks.
Re: Integrating PHP into menu templates
Posted: Thu Sep 06, 2007 3:23 am
by calguy1000
have you tried
if $node is an object (you can test with is_object )
then the array syntax may give you grief.
See also: is_array
Re: Integrating PHP into menu templates
Posted: Thu Sep 06, 2007 8:38 pm
by xnau
Yes--that's it. I learn so much in this forum!
thanks!
Re: Integrating PHP into menu templates
Posted: Sat Sep 08, 2007 12:52 pm
by Dr.CSS
[solved] ?