1

Joomla 3.6 + k2 2.7 hosted on my own linux server.

I am assuming someone else's webmaster job. He has had hundreds of k2 items on hte site, with a major problem: most of the articles have some inline javascript snippet(jwplayer) to play videos in them, but the width and height of the video player are set to fixed numbers instead of percentage and aspectratio. Now it is up to me to fix this issue. Of course I can edit the items from back-end one by one, but there are hundreds of them.

Since the modification of each item follows a certain pattern, I think I should be able to do it programatically. There are 3 possible ways I can think of: 1) Using phpmyadmin, directly edit the k2_item table's fulltext field. This is the most straightforward way, but I am not sure if directly editing database is going to cause some potential problem. Besides I am not very familiar with SQL, so I am reluctant to do it this way. 2) Hardcode some PHP file, get connected with the database, read the fulltext field, do the modification with PHP and put them back to the table. I am more comfortable with PHP, but I've never done such things before. 3) Is there any extension that can accomplish such job?

Which approach would be the best practice?

2

You can edit the K2 articles directly from the database using phpMyAdmin. That shouldn't be a problem. Just make sure you clear your Joomla and your browser cache in order to see the updated data. Also make sure you backup the table that you're updating first - since a global update on a table is typically hazardous.

1

Yes, there is a perfect extension for the job: Regular Labs (ex-NoNumber) DB Replacer.

I have used it successfully for years for similar tasks: batch Find & Replace of text in articles or K2 items directly in DB.

Highly recommended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.