Search
Other DB Replacer questions
Forum

Replacing snippet-tags: what tags do I use?

Frank van der Meer's Avatar Frank van der Meer
Hi Peter,

I’m migrating tot Joomla 4, and the syntax of Snippets don’t work anymore.

I read some posts on regularlabs, bought the DP Replacer to replace snippets that all have the same syntax: {snippet justaword}

Want to replace them by {snippet alias="justaword"}

What tags should I use to do the replacement? Can you help?

Thanks,
Frank
Peter van Westen's Avatar Peter van Westen ADMIN
Try this using Regular Expressions:
\{snippet ([^"\|]*)\}
Replace with:
{snippet alias="\1"}
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
DB Replacer doesn’t find any snippet in content/fulltext when I use \{snippet ([^"\|]*)\} in the search field

DP Replacer does find the word snippet in content/fulltext. When I press the Search button the maximum of 100 pages are found with that word in it. I.e. this tag: {snippet advertentie08}

So something is wrong with the syntax? Or do I have to do something extra?

Thanks,
Frank
Peter van Westen's Avatar Peter van Westen ADMIN
Have you switched the Regular Expressions option on?
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
You could also try:
\{snippet ([a-zA-Z0-9_-]+)\}
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
Wow, I overlooked that option. After putting it on, it seems to work great!
Thanks Peter!
Frank van der Meer's Avatar Frank van der Meer
One more question: it does some strange things in the rare cases that there is a tab-tag behind the snippet-tag.

{snippet twijfel-slot}{tab=Groene Wissels}
is i.e. transformed to:
{snippet alias="twijfel-slot}{tab=Groene Wissels"}

Any suggestions?
Peter van Westen's Avatar Peter van Westen ADMIN
Use this one instead:
\{snippet ([a-zA-Z0-9_-]+)\}
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
In search box, with regular expression on: \{snippet ([^"\|]*)\}
In replace box: \{snippet ([a-zA-Z0-9_-]+)\}
Results in for instance: {snippet advertentie08} will be replaced by: \{snippet ([a-zA-Z0-9_-]+)\}

Did I do something wrong?
Peter van Westen's Avatar Peter van Westen ADMIN
Replace with:
{snippet alias="\1"}
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
Ahhhhhhh, sorry, my mistake!
This works great!
Thanks again!
Frank
Frank van der Meer's Avatar Frank van der Meer
Hi Peter,
Using Joomla-articles and custom fields, this works great.

But something unexpected happens when using DP Replacer with Zoo-blogs: all content is stripped.

I select as Table ‘Zoo_item’
And as Colum ‘elements’

Search for: \{snippet ([a-zA-Z0-9_-]+)\}
Regular expression is on
Replace by: {snippet alias="\1"}

In the example everything looks OK (the same as Joomla-articles). I.e.
{snippet ttcameranu}{snippet alias="ttcameranu"}

But when I do the replacements, all content is stripped from the Zoo-blogs.

This is an example, there is nothing left, not on the front-end and not in the admin:
test.frankwandelt.nl/wandelen/wandelblogs/voetreis-naar-rome-1
This is the same article on my live site: www.frankwandelt.nl/wandelen/wandelblogs/voetreis-naar-rome-1

What should I do?

Thanks,
Frank
Peter van Westen's Avatar Peter van Westen ADMIN
I have no idea how and why that would happen.
Can you reproduce the issue again and again when placing back the backup of the database?
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
Hi Peter,
I’ve done exactly that three times before contacting you because I couldn’t believe this happening.

Yesterday I’ve only replaced snippets in 50 Zoo-blogs (I have about 700 blogs), and just now I’ve done a new serie of 50 blogs, with the same result, i.e. this one:
test.frankwandelt.nl/actieve-vakanties/d...nd-met-bagagevervoer

Best,
Frank
Peter van Westen's Avatar Peter van Westen ADMIN
Can you give me (super) admin, (s)ftp and database (PhpMyAdmin) access so I can take a look?
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
Ah, I see what the issue is.
Zoo stores the data in the 'elements' column as a json string.
You are replacing the string with a string that contains double quotes.
This makes the json string syntax invalid and 'corrupts' the Zoo item data.

You would need to escape the quotes, like:
{snippet alias=\"\1\"}
Please post a rating at the Joomla! Extensions Directory
Frank van der Meer's Avatar Frank van der Meer
Ah, this works great! A huge time-saver for me!
Thanks again,
Frank
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription