Page 1 of 1

[Solved] How to use smarty into php tag

Posted: Mon Aug 27, 2012 4:51 am
by uloloi
Hi, I'm trying to use a smarty var into a simple php tag like this

Code: Select all

{php}
$val = $smarty->get_template_vars('position');// $this->position;
echo $val;  //strpos_array($val, '.'); // Output is 1
{/php}
Well, I want to use the smarty $position, How can I do that in cmsms 1.11.x

Re: How to use smarty into php tag

Posted: Mon Aug 27, 2012 5:45 pm
by Dr.CSS
It might help if you can explain why you want to do this, what you expect to see on output etc...

Re: How to use smarty into php tag

Posted: Mon Aug 27, 2012 9:03 pm
by uloloi
ok, using the same template, I want to display breadcrumbs only on pages of a section, section 6. Topics or general sections:
1. About 2. Contact, 3. Services, 4. Products 5. Anything else, and 6. Articles of Interest

Into the section 6:
6. Articles of Interest (father)
6.1 Blah
6.1.1
6.1.2
6.2
6.2.1 ...

I'm looking for how to make the visit eg 6.1.1, known to belong to the parent 6 and if so show breadcrumbs :-[

Well, using {php} attempt to pass a variable smarty-> $ position, which in this case is 6.x for all the items inside, using strstr () for the first '.', So:
6 [.] 1.1 for example, etc, then know that belong to 6

Sorry for the doubt. But I think this example can serve other applications, but I do not know how to get the father

Re: How to use smarty into php tag

Posted: Mon Aug 27, 2012 9:22 pm
by mrenigma
There are several different methods to what you are looking for:
  1. You could create UDT (since using the {php} tags are quite insecure) and call that UDT within the template.
  2. You could use the module CGSimple, get the root and parent aliases (great documentation with the module on how to do this) and compare to the specific aliases you want to limit to.
  3. Create a specific template for that section so it only displays on the specified template
Hopefully this should point you in the right direction.

[Solved] Re: How to use smarty into php tag

Posted: Mon Sep 03, 2012 5:40 pm
by uloloi
Hi, thanks! CGSimpleSmarty was the solution, very useful!

Just an if in the template using:
{\$cgsimple->get_root_alias()}