Jump to content

[SOLVED] Features on product-list.tpl


Recommended Posts

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

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}

  • Thanks 1
Link to comment
Share on other sites

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

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

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

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

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

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

  • 9 months later...

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

  • 1 month later...
  • 3 years later...

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

  • 2 years later...

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

  • 1 month later...

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...