Integrating PHP into menu templates
Integrating PHP into menu templates
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?
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
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
Read about them here:
http://wiki.cmsmadesimple.org/index.php ... fined_Tags
Nullig
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Integrating PHP into menu templates
check out smarty.php.net/manual/en
there's a function in smarty called get_template_vars
there's a function in smarty called get_template_vars
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: Integrating PHP into menu templates
Cool, had a read of that, but how would I use it? $node->get_template_vars?calguy1000 wrote: check out smarty.php.net/manual/en; there's a function in smarty called get_template_vars
Re: Integrating PHP into menu templates
No, use:ahmednuaman wrote:Cool, had a read of that, but how would I use it? $node->get_template_vars?calguy1000 wrote: check out smarty.php.net/manual/en; there's a function in smarty called get_template_vars
{get_template_vars}
This stamp all note smarty variables.
If there are Array variables, you can check with:
{$your_array|print_r}
Alby
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Integrating PHP into menu templates
in php code you would:
Code: Select all
global $gCms;
$smarty =& $gCms->GetSmarty();
$myvar = $smarty->get_template_vars('myvar');
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.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Integrating PHP into menu templates
$node = $smarty->get_template_vars('node');
print_r( $node );
print_r( $node );
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: Integrating PHP into menu templates
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:
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.
Code: Select all
$node = $smarty->get_template_vars('node');
print_r($node);
echo $node['menutext'];

-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Integrating PHP into menu templates
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
Code: Select all
echo $node->menutext;
then the array syntax may give you grief.
See also: is_array
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: Integrating PHP into menu templates
Yes--that's it. I learn so much in this forum!
thanks!
thanks!
Re: Integrating PHP into menu templates
[solved] ?