ltempest Posted March 19, 2012 Share Posted March 19, 2012 Please help, I really need someone to respond and help me. I need to display one of my features within the product-list.tpl file. I currently have this code: {foreach from=$product.features item=feature name=features} {$feature.value|escape:'htmlall':'UTF-8'} {/foreach} But this returns evry feature and I only need it to return one of them. How do I target the feature I need. I assume I could use the ID of the feature from the database, but do not know how to code this. Please help! Thanks Lee Link to comment Share on other sites More sharing options...
phrasespot Posted March 21, 2012 Share Posted March 21, 2012 I need to display one of my features within the product-list.tpl file. modify as follows, replacing xxx with the name of the feature you are looking for, e.g color {foreach $product.features as $feature} {if $feature.name == 'xxx' }{$feature.value|escape:'htmlall':'UTF-8'}{/if} {/foreach} 1 Link to comment Share on other sites More sharing options...
ltempest Posted March 26, 2012 Author Share Posted March 26, 2012 Thanks for the reply, I copied your code and replaced the xxx but it breaks my layout, nothing appears. Do I need to remove the 'xxx' or just the xxx. I've tried both ways but it still does not work. Can I target by the ID in the database? Thanks again for the help. Link to comment Share on other sites More sharing options...
phrasespot Posted March 26, 2012 Share Posted March 26, 2012 Thanks for the reply, I copied your code and replaced the xxx but it breaks my layout, nothing appears Sorry my error. I small typo, forgot the s at the end of $product (copying from your post), should read $products. see below for correction. Do I need to remove the 'xxx' or just the xxx. I've tried both ways but it still does not work. If the feature you are targeting, for example, is named Voltage, then do {if $feature.name == 'Voltage' } Can I target by the ID in the database If you mean feature id, yes you can target id by using $feature.id_feature instead of $feature.name so you would do something like: {foreach $products.features as $feature} {if $feature.id_feature == 999 }{$feature.value|escape:'htmlall':'UTF-8'}{/if} {/foreach} replacing 999 with the relevant feature id Link to comment Share on other sites More sharing options...
ltempest Posted March 29, 2012 Author Share Posted March 29, 2012 Thanks for the reply, I have tried both your options but niether work, I get nothing, the page stops loading and I do not see anything on the page except the header area! I'm using v 1.4.7.0 could this be the reason? Thanks Lee Link to comment Share on other sites More sharing options...
phrasespot Posted March 29, 2012 Share Posted March 29, 2012 OK, do the following. 1- Locate /config/config.inc.php and set error display to on (currently should be off) 2- Copy and paste the following into relevant template at relevant location. {DEBUG} {foreach $products.features as $feature} {$feature.value} {/foreach} Try viewing the cats again. A new extra window will popup, copy everything in that new window into a text document and attach to your next post. If anything displays in category take a screen capture, upload somewhere and post a link (don;t attach to post, forum is broken) If not, note any errors that may display and let me know Link to comment Share on other sites More sharing options...
ltempest Posted March 30, 2012 Author Share Posted March 30, 2012 Phrasepot, With this code in the product-list.tpl I get this error and nothing displays: {foreach $product.features as $feature} {if $feature.name == 'Description' }{$feature.value|escape:'htmlall':'UTF-8'}{/if} {/foreach} Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/home/newnorth/public_html/themes/northgate/./product-list.tpl" on line 42 "{if $feature.name == 'Description' }{$feature.value|escape:'htmlall':'UTF-8'}{/if}" - Unexpected " }"' in /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templateparser.php(2855): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templateparser.php(2920): Smarty_Internal_Templateparser->yy_syntax_error(10, ' }') #2 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templateparser->doParse(10, ' }') #3 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile('{*?* 2007-2011 ...') #4 /home/ in /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431 No popup window appears. With this code in the product-list.tpl I do not get a display error, but get all the features and then get a pop up which contains the attached text: {foreach from=$product.features item=feature name=features} {$feature.value|escape:'htmlall':'UTF-8'} {/foreach} Thanks again for all the help, I could not have found a solution without your assistance. Regards Lee SmartyDebug.txt Link to comment Share on other sites More sharing options...
phrasespot Posted March 30, 2012 Share Posted March 30, 2012 You have forgotton the {DEGUB} line, that is why the new window did not open. Link to comment Share on other sites More sharing options...
ltempest Posted March 30, 2012 Author Share Posted March 30, 2012 I've now got this code in my template file: {DEBUG} {foreach $product.features as feature} {if $feature.name == 'Description' }{$feature.value|escape:'htmlall':'UTF-8'}{/if} {/foreach} And now get this error displayed within the page, but no popup: Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/home/newnorth/public_html/themes/northgate/./product-list.tpl" on line 38 "{foreach $product.features as feature}" - Unexpected "feature", expected one of: "$"' in /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templateparser.php(2855): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templateparser.php(2920): Smarty_Internal_Templateparser->yy_syntax_error(18, 'feature') #2 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templateparser->doParse(18, 'feature') #3 /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile('{*?* 2007-2011 ...') #4 /home/newnort in /home/newnorth/public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431 Line 38 is the foreach stement. Apologies for bombaring you with these posts, I'm totally lost and very grateful for your help. Lee Link to comment Share on other sites More sharing options...
phrasespot Posted March 30, 2012 Share Posted March 30, 2012 OK. My mistake. I shouldn't just guess and test it myself. Ignore everything said so far. Here is an example from the default install to display the feature under description if the the product has a feature 'Headphone'. Adjust as required for the feature you need to display. Code Result 1 Link to comment Share on other sites More sharing options...
ltempest Posted March 30, 2012 Author Share Posted March 30, 2012 Phrasespot, AWESOME that worked perfectly exactly what I wanted. Thank you so much for all your help. Lee Link to comment Share on other sites More sharing options...
Rahvin Posted January 16, 2013 Share Posted January 16, 2013 Hi, I'm trying something similar. I'd like to show some features of the product in the cart (shopping-cart-product-line.tpl) but unfortunately Phrasespots code does not work. {foreach $product.features as $feature} {$feature|@print_r} {/foreach} This is the output: Array ( [id_feature] => 7 [id_product] => 8 [id_feature_value] => 28 ) 1 Array ( [id_feature] => 8 [id_product] => 8 [id_feature_value] => 26 ) 1 I'd like to show the value of the product for the acutal language. How can I do this? I'm using Prestashop 1.5.3. Any help is really welcome . Link to comment Share on other sites More sharing options...
yoligrana Posted February 24, 2013 Share Posted February 24, 2013 Is there any hack or module to show the features on product listing category? Also is there any way of showing product as lists by default? Link to comment Share on other sites More sharing options...
jakubstaszak Posted November 27, 2016 Share Posted November 27, 2016 Is there any hack or module to show the features on product listing category? Also is there any way of showing product as lists by default? Maybe little too late for my solution, but aren't you looking for product combinations by accident? For the latter I have solution that we are polishing right now. Link to comment Share on other sites More sharing options...
Blue Bear Posted February 5, 2019 Share Posted February 5, 2019 Hi there Is there a way to call the feature of level two by id ? when I used for example {if $feature.id_feature == '24'} -> it's working {if $feature.id_feature == '123'} -> it's not working (this two have the same $product->id_category_default) And do you know how to remove a feature_id list of product ? I'm new to this language so I don't have the grammar For example {if $product->id_category_default && [exclude ??] $feature.id_feature == '24'} ?? Thanks a lot, Clément Link to comment Share on other sites More sharing options...
cvikenzi Posted April 5, 2019 Share Posted April 5, 2019 Hello, if you want add features to product list for each product, you can use this module. Module is working for prestashop versions 1.6.X and 1.7.X With this module, you can also show descriptions in products thumbnails and much more. 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