Joomla 4 Snippet not inserting variables

Search
Other Bug Reports questions
Forum

Joomla 4 Snippet not inserting variables

George Benson's Avatar George Benson
Ok so I have a new Joomla! 4.2.3 Stable [ Uaminifu ] 27-September-2022 15:35 GMT installation, Database Version 10.2.44-MariaDB, PHP Version 8.0.23. Site is hosted by InMotion Hosting on a VPS server that I control with a total of 4 websites - all of which are mine.

I have installed ONLY the Regular Labs Extensions as follows:
Extension Type Version
Advanced Module Manager Component Action Log Plugin System Plugin 9.3.0 PRO
Articles Anywhere System Plugin Editor Button Plugin 12.5.0 PRO
Articles Field Field Plugin 3.9.0 PRO
Better Frontend Link Module 1.1.2
Cache Cleaner Module System Plugin 8.2.0 PRO
Conditional Content System Plugin Editor Button Plugin 4.1.0 PRO
Content Templater Component Action Log Plugin System Plugin Editor Button Plugin 11.0.0 PRO
Regular Labs Extension Manager Component Action Log Plugin 8.2.0
GeoIP System Plugin Library 5.1.1
IP Login System Plugin 5.1.2 PRO
Keyboard Shortcuts System Plugin 2.0.0 PRO
Modules Anywhere System Plugin Editor Button Plugin 7.16.0 PRO
Quick Index System Plugin 3.2.2 PRO
ReReplacer Component Action Log Plugin System Plugin 12.4.0 PRO
Snippets Component Action Log Plugin System Plugin Editor Button Plugin 8.3.3 PRO
Sourcerer System Plugin Editor Button Plugin 9.2.3 PRO

I have created a single Snippet following the docs4.regularlabs.com/snippets/the-basics/creating-a-snippet

The snippet details are:
%year% - %company% - All rights reserved

I have created two variables:
Variable Key ="year" and Default Value = "2022" - Insert in Tag set to "YES" (ie:GREEN YES SHOWING)
Variable Key ="company" and Default Value = "Test Company, INC." - Insert in Tag set to "YES" (ie:GREEN YES SHOWING)

Options are all Default with Show in Editor Button List set to Only in admin.

I have tried creating a NEW Article as well as editing an existing Article and with both I use the Snippet Button under CMS Content. After clicking the Snippet Button I am presented with a modal window showing a single Snippet with the following:

ID="1", Alias="copyright", Title="copyright", Description="Test Copyright", Category="Copyright", Frontend="x", Status="✔"

I click on the Title which is "copyright" and the modal window disappears and the following is inserted into the article:
{snippet title="copyright" year="" company=""}

Am I correct that this is a BUG and in fact it should be auto filling the year and company with the variable information?
Peter van Westen's Avatar Peter van Westen ADMIN
No, it is not a bug.
The default value is used for when you do not pass the variables in the tag.
So:
{snippet title="copyright"}
Will result in:
2022 - Test Company, INC. - All rights reserved
Please post a rating at the Joomla! Extensions Directory
George Benson's Avatar George Benson
Ok. That does work. I guess I was confused because I tried using the Button. Apparently you wouldn't be able to use the Button to insert this then? I mean I tried inserting it by clicking on all three "Buttons" including ID, Alias & Title and each time it did not produce the code:
{snippet title="copyright"}
instead it produced the following:
{snippet id="1" year="" company=""}
{snippet alias="copyright" year="" company=""}
{snippet title="copyright" year="" company=""}
depending on which button you click on.

I mean the only way I can seem to find to reproduce:
{snippet title="copyright"}
is to hand type the actual text or to use the button, click on title and delete the:
year="" company=""
Is this correct? That you have to hand type the actual text? Or am I missing something else?
Peter van Westen's Avatar Peter van Westen ADMIN
Switch off the "Insert in Tag" for the variables.
Please post a rating at the Joomla! Extensions Directory
George Benson's Avatar George Benson
Ok. Once again that works. I guess I was confused by the wording of the Tip that comes up when you haver over the little i in the circle (to the right of the column label "Insert in Tag") that says, "Select to have the editor button insert this variable key as an attribute in the snippet tag." I read that text to be that it was going to insert the actual value for me. A possible way to reword this to make it clearer is, "Select to have the editor button insert the option to change this variable key's value as an attribute in the snippet tag."

As a side note - the text of that goes off the screen and you can't read all of it in Chrome.

So again - Thanks for your help! I continue to recommend your products as I find they are the best out there for what they do and they continue to be the only extensions I use except for Akeeba backup. Keep up the great work!
Peter van Westen's Avatar Peter van Westen ADMIN
You always have the option to override that value. Whether it is inserted via the editor button (and you enter a value) or whether you add the attribute and value manually in the editor.

That option - like the hover description says - only adds it as an attribute into the tag, when choosing it via the editor button.
Please post a rating at the Joomla! Extensions Directory
You can only post on this forum if you log in