Jump to content

Module for showing different icons if the product is for man, woman or single.


Recommended Posts

I'm the owner of that web and I did that picture. I know how it's made on that web, but I want to do it different in prestashop. I would like to use a module that can show that icon for me in the description of the product based on my category choice of male, female or single. I don't want to modify the pictures.

 

Thank you.

Share this post


Link to post
Share on other sites

If you can, you can code in product-list.tpl a thing like that: 

 

if product.tag = male
   <img style="position:absolute" src="male.png"/>

elseif product.tag = female

  <img style="position:absolute" src="female.png"/>

elseif product.tag = single

   <img style="position:absolute" src="single.png"/>

 

Send me a PM, if you want to know more ;)

Share this post


Link to post
Share on other sites

Thank you. What is product.tag? Is a category? I don't know very well how to controll this variable. I also have doubts about the position of the picture with that code.

Share this post


Link to post
Share on other sites

An example of using tag 

if isset($product->tags) && $product->tags}
{assign var='id_lang' value=Language::getIdByIso($lang_iso)}
   {assign var='productTags' value=$product->tags}
   
       {foreach from=$productTags[$id_lang] item=productTag name=productTags}
        {if $productTag=='spotify'}
        <img src="{$base_dir}/images/icones/image4.png" width="60" alt="Spotify" title="Spotify">
        {/if}
        {if $productTag=='bluetooth'}
        <img src="{$base_dir}/images/icones/image5.jpg" width="60" alt="Bluetooth" title="Bluetooth">
        {/if}
        {if $productTag=='upnp'}
        <img src="{$base_dir}/images/icones/image6.png" width="60" alt="UPNP" title="UPNP">
        {/if}
        {if $productTag=='usb'}
        <img src="{$base_dir}/images/icones/image7.png" width="60" alt="USB" title="USB">
        {/if}
        {if $productTag=='wifi'}
        <img src="{$base_dir}/images/icones/image8.png" width="60" alt="Wifi" title="Wifi">
        {/if}
        {if $productTag=='apple'}
        <img src="{$base_dir}/images/icones/image9.png" width="60" alt="Airplay" title="Apple">
        {/if}
        {if $productTag=='airplay'}
        <img src="{$base_dir}/images/icones/airplay.png" width="60" alt="Airplay" title="Airplay">
        {/if}     
       {/foreach}
{/if}
  • Like 1

Share this post


Link to post
Share on other sites

semor - veery nice know how :)

with this idea, we can do almost everything with "additional" features (like badges, text informations etc.) on product list

im so impressed with this :D

Share this post


Link to post
Share on other sites

Vekia is this ironic? :)

This is not much, but when i can, i try to help the community with my tricks ;)

And you have right, we can do anything with additional features even using tag block module, just make conditions about a particular tag to not display the tag

 

Have a good day.

 

(Excuse me, if my English is bad... )

Share this post


Link to post
Share on other sites

Vekia is this ironic? :)

 

This is not much, but when i can, i try to help the community with my tricks ;)

And you have right, we can do anything with additional features even using tag block module, just make conditions about a particular tag to not display the tag

 

Have a good day.

 

(Excuse me, if my English is bad... )

 

 

no, it's not ironic.

im impressed because .... when i wanted to add some features like that (for example man/woman) i always did that with modification of controllers, database etc (new field in database, new field in object definition, modification of admin template, a lot of work)

 

now i see that i can achieve this without modifications of controllers, i never thought about that :D

thank you :)

  • Like 1

Share this post


Link to post
Share on other sites

Thx for this.

Really helpful.

I will definitely use this on my shop.

Is it possible to put the picture over the existing product picture?

Or better question where to put this piece of code that checks tags, and displays them.

Share this post


Link to post
Share on other sites

This piece of code in product.tpl in your template folder ;)

 

And to put the picture over the existing product picture, use CSS like that

img.male{
position:absolute;
top:0px;
right:0px}

Share this post


Link to post
Share on other sites
  • 5 months later...

 

An example of using tag 

if isset($product->tags) && $product->tags}
{assign var='id_lang' value=Language::getIdByIso($lang_iso)}
   {assign var='productTags' value=$product->tags}
   
       {foreach from=$productTags[$id_lang] item=productTag name=productTags}
        {if $productTag=='spotify'}
        <img src="{$base_dir}/images/icones/image4.png" width="60" alt="Spotify" title="Spotify">
        {/if}
        {if $productTag=='bluetooth'}
        <img src="{$base_dir}/images/icones/image5.jpg" width="60" alt="Bluetooth" title="Bluetooth">
        {/if}
        {if $productTag=='upnp'}
        <img src="{$base_dir}/images/icones/image6.png" width="60" alt="UPNP" title="UPNP">
        {/if}
        {if $productTag=='usb'}
        <img src="{$base_dir}/images/icones/image7.png" width="60" alt="USB" title="USB">
        {/if}
        {if $productTag=='wifi'}
        <img src="{$base_dir}/images/icones/image8.png" width="60" alt="Wifi" title="Wifi">
        {/if}
        {if $productTag=='apple'}
        <img src="{$base_dir}/images/icones/image9.png" width="60" alt="Airplay" title="Apple">
        {/if}
        {if $productTag=='airplay'}
        <img src="{$base_dir}/images/icones/airplay.png" width="60" alt="Airplay" title="Airplay">
        {/if}     
       {/foreach}
{/if}

Hi I try use this code in my store (presta 1.6 & default bootsrap theme) but I have blank page... How to use correctly this code?

Share this post


Link to post
Share on other sites

vekia ;D thank you for drawing my attention to the debugging :D i found error It was the last {/if} in code

Strict Standards: Declaration of Dispatcher::loadRoutes() should be compatible with that of DispatcherCore::loadRoutes() in /skleptest/override/classes/Dispatcher.php on line 16 Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/skleptest/themes/default-bootstrap/product.tpl" on line 793 "{/if}" unexpected closing tag' in /skleptest/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /skleptest/tools/smarty/sysplugins/smarty_internal_compilebase.php(170): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unexpected clos...', 793) #1 /skleptest/tools/smarty/sysplugins/smarty_internal_compile_if.php(197): Smarty_Internal_CompileBase->closeTag(Object(Smarty_Internal_SmartyTemplateCompiler), Array) #2 /skleptest/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Ifclose->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #3 /skleptest/tools/smarty/sysplugins/smarty_in in /skleptest/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 667

Now i use

{* TAGS *}	

{assign var='id_lang' value=Language::getIdByIso($lang_iso)}
   {assign var='productTags' value=$product->tags}
   
       {foreach from=$productTags[$id_lang] item=productTag name=productTags}
        {if $productTag=='H.264'}
        <img src="{$base_dir}/img/cms/Ikony/h264.png" width="60" alt="H.264" title="H.264">
        {/if}
          
       {/foreach}

{* /TAGS*}

and error is

Strict Standards: Declaration of Dispatcher::loadRoutes() should be compatible with that of DispatcherCore::loadRoutes() in /skleptest/override/classes/Dispatcher.php on line 16 

but line 16 is empty ;D

 

wX7N0uP.png

Edited by m0n0 (see edit history)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More