[Solved] How to use smarty into php tag

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

[Solved] How to use smarty into php tag

Post 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
Last edited by uloloi on Mon Sep 03, 2012 5:42 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: How to use smarty into php tag

Post by Dr.CSS »

It might help if you can explain why you want to do this, what you expect to see on output etc...
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

Re: How to use smarty into php tag

Post 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
mrenigma
Forum Members
Forum Members
Posts: 48
Joined: Fri Aug 05, 2011 3:43 pm
Location: London, United Kingdom

Re: How to use smarty into php tag

Post 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.
~ Life is like water, every movement you make changes the way it flows ~
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

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

Post by uloloi »

Hi, thanks! CGSimpleSmarty was the solution, very useful!

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

Return to “Developers Discussion”