V
V
vikin_glory2021-04-21 01:19:22
MODX
vikin_glory, 2021-04-21 01:19:22

How to correctly assign classes to images in the tpl.msGallery conditional modifier for old_price, new and regular products?

Hello. Help, please, to understand.
We are talking about the tpl.msGallery chunk.
Stuck on the implementation of the NEW and SALE classes, which should be assigned to the main image in the product card. NEW and SALE work, but in the case of a normal product, SALE is displayed again, although it should not. Can you throw in a couple of fresh ideas? The second day I fight.
Here is the code for conditional output modifiers that I use, the last else condition categorically does not want to be executed:


            
                <img src="{$file['medium']}" alt="{$file['description']}" title="{$file['name']}" class="item">
            
        

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Lunegov, 2021-04-21
@vikin_glory

Greetings! To begin with, it is worth writing the then
modifier code in quotes:


    
<img src="{$file['medium']}" alt="{$file['description']}" title="{$file['name']}" class="item">
    

And secondly, pay attention that in any case you get the same line with a difference of one word, so you can write the condition like this:
<img src="{$file['medium']}" alt="{$file['description']}" title="{$file['name']}" class="item">

Plus got rid of the second else .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question