Jump to content

[Solved] Modify the core of product-list.tpl


Recommended Posts

Hi everybody.

 

I would like to modify the product-list.tpl to allow two type of display depending on the name of a product.

 

A programmer changed the core of product-list.tpl in a way that when you click on a product it execute a javascript function in a <div>...</div> which display a link to an embed media.

 

Now we want to allow the normal product-list.tpl display for only one product knowing its name.

 

for example in product-list.tpl we have tha following:

 

<div>...</div>

 

{if isset($products)}

  {if $products->name|escape:'htmlall':'UTF-8' == "Test"}

   .....

   .....Normal product-list.tpl code

   .....

   {else}

   ....

   ....Custom code with the javascript function

   ....

   {/if}

{/if}

 

The problem is with the if statement where i get the product name. I saw in forums that the way to get a product name is $products->|escape:'htmlall':'UTF-8'. So i look for the product's name value (value= Test), if yes i display the normal product-list.tpl if no i display the custom code.

 

The custom code and the normal code are working flawlessly each on their side, but not with this if statement. With this one it is executing only the custom code for every product even the one with the name "Test".

 

When i change it for {if $products.name = "Test"} it execute only the normal code. 

 

I am not expert in prestashop, and maybe the programmer who did the custom code before me set something i dont know, but for me this if statement is correct.

 

Does anybody know what is the problem here or even has a clue about it?

 

Thank you in advance.

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

Thanks sandipchandela for your reply.

Unfortunately i already tried that but nothing changed.

 

Actually i have a question regarding this object $produits.name:

- does it get its data from the table ps_product? Because when you looked for the field "name" in this table, its not there. So maybe that is the problem?!

 

So if the name is not record in the ps_product table where can i found it?

 

Thank you.

Link to comment
Share on other sites

i am using 1.6.0.14

 

For the spell, your are right. I actually meant $product.name...

 

I tried the {$products|@var_dump},it display a multidimensional array with all the attributes and values of the products on the list.

 

So i look for the array element i wanted.

 

And i replaced 

{if $products->name|escape:'htmlall':'UTF-8' == "Test"}

with the following

{if $products[0]["name"] == "Test"}

And it works, i have two different display on the product-list depending on the name of the product.

 

Thank you archSandy for your help.

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