Jump to content

Lookup The Value Of A Feature In Tpl?


Maury Markowitz

Recommended Posts

when you say, feature, what do you mean. It is really easy to access php value in a tpl file but i need more information before i am going to type out an answer. Smarty can do some inTPL maths on a value aswell if needed.

 

I have a feature called "Nameplate" with a value that is either null or a number like "2000".

 

I know I can loop over the array of Features and look at the name, like this…

 

 

{foreach from=$features item=feature}

<p>{$feature.name}, {$feature.value}</p>

{/foreach}

 

 

But what I want to do is easily find that one single Feature, the one called "Nameplate", and then get it's value. I suspect there's just a little syntax I need to know to do this…

Link to comment
Share on other sites

Only started looking into smarty today, so could be wrong but cant you use array.key:

 

{$features.nameplate}

 

i think this is right. this assumes the $features is an array and that 'nameplate' is a key. the code above will return the value of the key nameplate in the array held in $features

 

they will be capitals sensitive. you will not need to loop to get this single value.

Edited by shoulders (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...