Search
Other Snippets questions
Forum

Snippet syntax no longer working as expected - selecting all instead of keyword

Christopher R Moggia's Avatar Christopher R Moggia
Hello Peter.

I use the following code {snippet system17|ada|Monsido}

The Snippet's alias is "system17" and I send two variables, the category (ada) and the product (Monsido).

For the last 3 years this section of code in the snippet pulled ONLY those organizations that used Monsido.

$sql = "SELECT * FROM `database`.`systems_2017` WHERE `\1` like '%\2%' ORDER BY SchoolDistrict ASC LIMIT 5";

But now it seems to be pulling ALL organizations, not just the ones that use that product in that category.

I've upgraded to 3.9.1x and version 8.04 pro of snippets. I think the syntax may have evolved and I wasn't aware of it.

Can you provide any insight into why this might be happening?

The variables are being passed correctly because I can see them in other parts of the code.

What is breaking is only the synatx around the selection "WHERE"
Peter van Westen's Avatar Peter van Westen ADMIN
You should update your syntax to the new attribute syntax.
Please read the documentation on the syntax:
docs3.regularlabs.com/snippets/the-basics/inserting-a-snippet
docs3.regularlabs.com/snippets/going-fur...ing-dynamic-snippets

(Old syntax was deprecated with version 7.0.0 back in March)
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
So my new snippet should be:

{snippet alias ="system17" 1= "ada" 2="Monsido"}

????

It used to be {snippet system17|ada|Monsido}

I've tried it and it's not working. THank you for your support. Once I figure this out I can fix the site.
Christopher R Moggia's Avatar Christopher R Moggia
THis is the actual code of the snippet itself "system17"

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
No, it should be something like:
{snippet alias="system17" key="ada" value="Monsido"}
And then change your snippet to:
$sql = "SELECT * FROM `database`.`systems_2017` WHERE `%key%` like '%%value%%' ORDER BY `SchoolDistrict` ASC LIMIT 5";
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
THat worked! Peter you are a God!

Thank you Thank you Thank you!

P.S. I'm barely able to program in PHP, but your Snippets program encouraged me and pushed me to get this to work. Now I have a 1,000 member site where we discuss these various school programs and how to integrate them.

I am so very thankful for Regular Labs!
Christopher R Moggia's Avatar Christopher R Moggia
Peter, one last HUGE favor. The select code in SQL appears to stil be selecting ALL of the school districts, not just the ones with the actual value. Any other suggestions?

I'm using this snippet code:
{snippet alias="system17" key="ada" value="Monsido"}

ANd this SQL code below, but it's pulling ALL of the organizations instead of just the 6 that are using the Monsido app.

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
Well, your standards of being a god are very low 😁

PS: I recommend you read this to find out more on how to use the database connections inside Joomla:
docs3.regularlabs.com/sourcerer/the-basics/using-php-code
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Also, I recommend you clean up that PHP code, so you don't have all the commented-out stuff in there.
And to test if the snippet output is as you want it, disable Sourcerer temporarily, or change the {source} tags to {xsource} or something, to see the PHP output on the frontend.
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
Thanks for the tip about changing source to xsource. I did, and I can see it is not passing through the second variable.


$sql = "SELECT * FROM `schoo126_sd`.`systems_2017` WHERE `ada` like '' ORDER BY `SchoolDistrict` ASC"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "
Peter van Westen's Avatar Peter van Westen ADMIN
Hmmm, it might be due to the percentages in the code that confuses Snippets... hold on...
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Nope, it should work, and working on my tests here...

Can you give me (super) admin and (s)ftp access so I can take a look?
And tell me on what url I can see/reproduce the issue.
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
Confidential information:
(hidden)
Christopher R Moggia's Avatar Christopher R Moggia
Are the double %% causing the issue? Or the use of the " ' " instead of the ' ` "?

The value is getting passed through by your snippets, because the first sentence says "School Districts in California that use "value" - and the Value is coming through. So it's just something strange about the sql code intepreting the double %% maybe ?
Peter van Westen's Avatar Peter van Westen ADMIN
The provided login doesn't work. I would also need the (s)FTP access...
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
username: jreviews, not previews, sorry.
Christopher R Moggia's Avatar Christopher R Moggia
Confidential information:
(hidden)
Christopher R Moggia's Avatar Christopher R Moggia
Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
I have bee able to reproduce the issue on my local setup now... I'll see if I can fix it...
Please post a rating at the Joomla! Extensions Directory
Christopher R Moggia's Avatar Christopher R Moggia
OK great. Thank you!!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription