Search
Other Snippets questions
Forum

IF statement not working?

Manfred Twrznik's Avatar Manfred Twrznik
Hi,
I am using sourcerer free and snippets pro - both freshly downloaded.

the following snippet
{source}{if JPG} <div style="margin: auto; width: 100%; display: grid;">
<div style="margin: auto; align-self: center;">
<table>
<tbody>
<tr>{/if}{/source}
{source}
<td>&nbsp;<img src="images/%JPG%.jpg" alt="%TITEL%" width="%WIDTH%" height="%HEIGHT%" style="float: left;" /></td>
<td><span style="text-decoration: underline;">%TITEL%</span><br />%TEXT%</td>
{if !INTABLE}{source}
</tr>
</tbody>
</table>
</div>
&nbsp;</div>
<p><br /><br />Für weitere Informationen kontaktiere uns bitte

shows the output



What do I wrong?

Regards, Manfred
Peter van Westen's Avatar Peter van Westen ADMIN
Why are you using the {source} tags?
They make no sense there.
Also you have 3 opening {source} tags and just 1 closing {/source} tag.

And is this on Joomla 3 or 4?
Please post a rating at the Joomla! Extensions Directory
Manfred Twrznik's Avatar Manfred Twrznik
Thanks for your very quick answer!
You are right, I did forget one closing {/source} tag.

But regardless if I use the Source-Tags correct (which I think, I need, when entering pure html - don't I?) or if I remove them, the result is just the same:

I see both {if...} and {if} tags on the website, similar to the image in the first post.

It is Joomla 4.1.5 and Snippets v8.3.2 [PRO]
Peter van Westen's Avatar Peter van Westen ADMIN
Why do you need to insert it as HTML? You can just switch to the HTML view in the editor and enter it there. I see no need for Sourcerer.

Also, the placement of the {if} tags will cause broken HTML structures if they don't pass, leaving half a table or orphan <td> tags.

I recommend you first try with a very simple snippet without any weird HTML structures...
Please post a rating at the Joomla! Extensions Directory
Manfred Twrznik's Avatar Manfred Twrznik
So I did what you said:

Simple Snippet:


Call of the snippet:


Outcome:


What is wrong?
Peter van Westen's Avatar Peter van Westen ADMIN
Issue was with a bug in Snippets with handling variable names containing uppercase characters.

Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Manfred Twrznik's Avatar Manfred Twrznik
Unfortunately same output with development version.

I did install it, did change something in the snippet (added "Development Version" in the main-part outside the if), and I did clear all the cache . the only thing that changed in the output are the new words "Development Version"...
Peter van Westen's Avatar Peter van Westen ADMIN
Ah, it seems to help if I actually push the changes to the zip ?
Try now:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Manfred Twrznik's Avatar Manfred Twrznik
Step by step...

It did help for the normal if, but not for {if !INTABLE}...
Peter van Westen's Avatar Peter van Westen ADMIN
Should be fixed now...
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Manfred Twrznik's Avatar Manfred Twrznik
Yes!!! Now it works fine!

Thank you for the great support and also thanks for your great extensions!

Regards, Manfred
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The fix will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription