Maury Markowitz Posted March 6, 2013 Share Posted March 6, 2013 I have a Feature called nameplate that holds a number. I'd like to use that number in a formula on my product page. It's just the current price divided by that number. How do I fetch the value of a named Feature in smarty? I suspect it's easy… Link to comment Share on other sites More sharing options...
shoulders Posted March 6, 2013 Share Posted March 6, 2013 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. Link to comment Share on other sites More sharing options...
Maury Markowitz Posted March 6, 2013 Author Share Posted March 6, 2013 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 More sharing options...
l3msip Posted March 6, 2013 Share Posted March 6, 2013 (edited) Only started looking into smarty today, so could be wrong but cant you use array.key: {$features.nameplate} Edited March 6, 2013 by l3msip (see edit history) Link to comment Share on other sites More sharing options...
Maury Markowitz Posted March 7, 2013 Author Share Posted March 7, 2013 {$features.nameplate} Well that is simple! Let me try it… Link to comment Share on other sites More sharing options...
shoulders Posted March 7, 2013 Share Posted March 7, 2013 (edited) 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 March 7, 2013 by shoulders (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now