Jump to content

Several {if} statements combined to one? Not working?


-M-

Recommended Posts

I thought I had this nailed, however the outcome is not what was to be expected. :(

 

I have this piece of code:

 

           {if {$configoption.optionname} eq "500 accounts / 20000 MB (1000 GB)"}
            {$configoption.optionname|replace:'500 accounts / 20000 MB (1000 GB)':'500 / 20000 MB / 1000 GB'}
           {elseif {$configoption.optionname} eq "SpamAssassin & Kaspersky anti-virus"}
            {$configoption.optionname|replace:' anti-virus':''}
           {elseif {$configoption.optionname} eq "Full backup plan with several restores a year"}
            {$configoption.optionname|replace:' with several restores a year':''}
           {else}
           {$configoption.optionname}
           {/if}

 

In the above code, it will only replace the first one, after that it outputs everything as normal (no further replacements).

 

It should apply all replacements and put the rest of the (remaining) options out as they were entered.

 

I am guessing I should use something else in here other than {if} and {elseif}, however I have no clue on what to use? Because if I re-read the above code, the first {if} is processed and then goes back to outputting the rest under {$configoption.optionname}, right?

 

//added reason

 

I am doing this, because the cart window is a bit to small, therefor I am shortening things in the cart section. I did try to resize the columns, but that made things look ugly / messy and therefor it's not an option. :)

Link to comment
Share on other sites

Hi Brian,

 

Well even without the brackets as you mention, it still stops after the first replace result and doesn't process the others.

 

As an example:

 

           {if $configoption.optionname eq "500 accounts / 20000 MB (1000 GB)"}
               {$configoption.optionname|replace:'500 accounts / 20000 MB (1000 GB)':'500 / 20000 MB / 1000 GB'}
           {elseif $configoption.optionname eq "SpamAssassin & Kaspersky anti-virus"}
               {$configoption.optionname|replace:' anti-virus':''}
           {elseif $configoption.optionname eq "Full backup plan with several restores a year"}
               {$configoption.optionname|replace:' with several restores a year':''}
           {else}
           {$configoption.optionname}
           {/if}  

 

//small edit

 

Can it be that the culprit is the '&' symbol?

Because I checked the other replacements and they work, except for the 'SpamAssassin & Kaspersky anti-virus' one. The first and last replacement actually works, which I just noticed now.

Edited by MvdL1979
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated