Integrating PHP into menu templates

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
ahmednuaman

Integrating PHP into menu templates

Post 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?
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Integrating PHP into menu templates

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Integrating PHP into menu templates

Post by calguy1000 »

check out smarty.php.net/manual/en


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.
ahmednuaman

Re: Integrating PHP into menu templates

Post 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?
alby

Re: Integrating PHP into menu templates

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Integrating PHP into menu templates

Post by calguy1000 »

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.
ahmednuaman

Re: Integrating PHP into menu templates

Post by ahmednuaman »

Ok, what if the var is:

Code: Select all

$node->hierarchy
???
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Integrating PHP into menu templates

Post by calguy1000 »

$node = $smarty->get_template_vars('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.
ahmednuaman

Re: Integrating PHP into menu templates

Post by ahmednuaman »

Cool thanks!
xnau
Forum Members
Forum Members
Posts: 33
Joined: Sun Apr 15, 2007 6:53 pm

Re: Integrating PHP into menu templates

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Integrating PHP into menu templates

Post by calguy1000 »

have you tried

Code: Select all

echo $node->menutext;
if $node is an object (you can test with is_object  )
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.
xnau
Forum Members
Forum Members
Posts: 33
Joined: Sun Apr 15, 2007 6:53 pm

Re: Integrating PHP into menu templates

Post by xnau »

Yes--that's it. I learn so much in this forum!

thanks!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Integrating PHP into menu templates

Post by Dr.CSS »

[solved] ?
Locked

Return to “Layout and Design (CSS & HTML)”