DB Replacer entire DOM in articles?

Search
Other Pre-Sale questions
Forum

DB Replacer entire DOM in articles?

Finn Williams's Avatar Finn Williams
Hi there Regular Labs / Peter,

I’m planning to purchase the pro version of DB Replacer because I’m facing a major update of many Joomla articles in 5 languages. The basic HTML structure is the same for all languages, but a new layout requires the HTML structure to be modified without replacing the content of the inner DIVs. It’s the surrounding structure that needs to be wrapped in a new way. Certain content structures also need to be rearranged slightly. All content has sensible “classes.”

I’ve tried using (* = All), but I’m not entirely sure I understand it.

Find:
<div class="content"><p>*</p></div>


Change to:
<div class="content"><div class="new"><ul><li><p>*</p></li></ul></div></div>


In other words, is it possible to take the entire DOM of an article and change it to another DOM while preserving (*) the content/snippets and other language-related elements?

I hope this makes some sense to you. This would be an enormous time saver for me if you could give me a hint on that.
/ Ulric
Peter van Westen's Avatar Peter van Westen ADMIN
You can use Regular Expressions.
See: docs4.regularlabs.com/dbreplacer/tutorial/regular-expressions
Please post a rating at the Joomla! Extensions Directory
Finn Williams's Avatar Finn Williams
Thanks for your reply – I’ve looked at docs4.regularlabs.com/dbreplacer/tutorial/regular-expressions , but it doesn’t immediately make sense for my challenge of performing advanced search and replace to change the DOM in articles while preserving the content. I guess I’ll need to dive deeper into regular expressions. Can you refer me to more detailed beginner tutorials?

Best regards,
Ulric
Peter van Westen's Avatar Peter van Westen ADMIN
Please only use the "confidential" tags to hide confidential info, like login details.

You could do something like:
^\s*<div class="content"><p>(.*?)</p></div>\s*$
Replace with:
<div class="content"><div class="new"><ul><li><p>\1</p></li></ul></div></div>

But depends on the actual syntax of the html. There is probably whitespace between the html tags you need to account for.
I guess I’ll need to dive deeper into regular expressions.
Correct.
Can you refer me to more detailed beginner tutorials?
Also in the documentation. Please read that first:
docs4.regularlabs.com/dbreplacer/tutoria...-regular-expressions
Please post a rating at the Joomla! Extensions Directory
Finn Williams's Avatar Finn Williams
Thanks, Peter – It might be just a bit too advanced for me; after all, I’m only human at the time 🙂 But I’ll dive into it a bit and see if I can succeed by searching and replacing small chunks over several attempts. Otherwise, it might end up being the big manual overhaul.

P.S. Sorry for writing "confidential" – it was more to hide my incompetence.

Thanks for now!
Best, Ulric
Peter van Westen's Avatar Peter van Westen ADMIN
If it matches your setup and need, you can simply replace:
<div class="content"><p>
with:
<div class="content"><div class="new"><ul><li><p>
And replace:
</p></div>
with:
</p></li></ul></div></div>
Please post a rating at the Joomla! Extensions Directory
Finn Williams's Avatar Finn Williams
Yes, that’s about as far as my brain can take me right now: searching and replacing at the beginning and then at the end to preserve the content – and the free version of Replacer can handle that just fine. I was thinking I could further optimize it with the pro version and regular expressions and make a million in 20 seconds, but regular expressions are something I currently don’t have deeper knowledge of, and they’re quite advanced.

Still, I don’t understand the asterisk (*). Is there any way I can use it simply, or is it part of understanding regular expressions?
"You can match the entire value of a field by placing a single asterisk * in the search area."

There’s only one way to manage regular expression – study and get to know them! 🙂
Tanks again Peter / Ulric
Peter van Westen's Avatar Peter van Westen ADMIN
The * placeholder can only be use to replace the entire content of a cell. Not part of it. That requires Regular Expressions.
Please post a rating at the Joomla! Extensions Directory
Finn Williams's Avatar Finn Williams
Okay, but what is a cell/field (entire content of a cell) in the database as opposed to a table – Could it be an article in the table content?
Peter van Westen's Avatar Peter van Westen ADMIN
With a cell I mean the column value of a row. So the introtext or fulltext of a content item for example.

But, I offer no support on the free versions of my extensions.
If you have further questions and need help on how to do things, please buy a subscription for DB Replacer.
Please post a rating at the Joomla! Extensions Directory
Finn Williams's Avatar Finn Williams
Yes, I completely understand, and it’s been a great help so far. That’s why I’ve registered and purchased a pro subscription of DB Replacer for my own small setup. I’ll probably have a few questions a long the way.

Best regards Ulric
You can only post on this forum if you log in