Page 1 of 1

Calling varibles from a page

Posted: Fri May 02, 2008 2:20 pm
by dwinters
I am sure this is in help somewhere but I have been searching for 4 hours and cant find

So really sorry if this is a simple one but.....

I have installed a UDT to help me see the variables I could use in a page / template / global block etc

// get a list of all of the smarty assigned variables
// user defined tag named "get_template_vars"
global $gCms;
$tpl_vars = $gCms->smarty->get_template_vars();
print_r( $tpl_vars );

And then try to use the vars I have found out about -- but cant seem to call them

Have tried {eval $var=content_title}
{eval $var=[content_title]}
{echo $var=[content_title]}
{content_title}
{smarty.get.content_title}

What is the right syntax!??

Re: Calling varibles from a page

Posted: Fri May 02, 2008 2:25 pm
by calguy1000
1.  There is an already existing {get_template_vars} plugin.  You didn't have to write a UDT
    go to Extensions >> Tags to see a list of the smarty tags that were provided by CMS Made Simple
    on most of the tags there is a help list on how to use them

2.  See http://smarty.php.net/manual/en

Re: Calling varibles from a page

Posted: Mon May 12, 2008 3:18 pm
by dwinters
Thanks - but still struggling with the syntax after reading the smarty site.
Do you have an example that might help me?

I found the UDT shows loads more variables for possible use than the built in one, is there a reason for this?


Also How do I close a post / topic off?

Re: Calling varibles from a page

Posted: Thu May 15, 2008 10:18 am
by gap_tooth_clan
I have had the same problem, I keep coming up with problems that would be easily solved with access to these variables.

My problem was I wanted to display either the page title or if it was set the page description as the page title for seo purposes, I tried to work out a solution in smarty for ages but it was just not working.

I found this post and thought it would be of some use but I did not know what to do with {get_template_vars} even after looking through the smarty manual I was still getting nowhere.

In the end I  used a UDT

global $gCms;
$pageinfo = &$gCms->variables['pageinfo'];

if ($pageinfo->content_titleattribute != '') {
  $result = $pageinfo->content_titleattribute;
} else {
  $result = $pageinfo->content_title;
}
echo $result;

I would be very interested in finding out how to do this with smarty.

Or is this the best way to handle this type of function keeping things seperated from the template?

Re: Calling varibles from a page

Posted: Thu May 15, 2008 2:20 pm
by calguy1000
I know the page title is available in smarty, but I don't think the title attribute is, so your solution is probably pretty much what I would have done.