Links from Neatline - Open in New Tab

Hi all,

We have created a Neatline exhibit that includes a lot of links to outside web pages. After putting those links in, we decided it would be better to make them open in a new tab (since Neatline takes a while to load). I know we can go through and individually change each link (adding target="_blank" to the HTML or using the editor), but was wondering if there was a way to update them all at once and save some time. This might be impossible, but everyone on our project is very new to this sort of thing, so we thought we would check.

Any ideas?

Thanks,
Abigail

Where are the links located? If you have access to the database they're in the records' body, for example, you could use a MySQL query along the lines of

UPDATE neatline_records SET body=REPLACE(body,"<a href","<a target='_blank' href") WHERE exhibit_id=#;

If I had to do this (and this is going to sound complicated), I would first create a mysql dump of the Neatline records table. Something like this (using git to version if there's a mistake):


$ mkdir tmp
$ cd tmp
$ git init
$ mysqldump -u [username] -p [omeka_database] omeka_neatline_records > neatline_records.sql
$ git add neatline_records.sql
$ git commit -m "Clean database dump"

Then, open neatline_records.sql up with your favorite text editor (Sublime Text, Atom.io, or vim) and do a find-and-replace on the anchor tags. Then you can do a search-and-replace of 'href="' with 'target="_blank" href="'. Save the file after you're done and then add that table back to the database:


$ mysql -u [username] -p [omeka_database] < neatline_records.sql

If it's messed up, you can then just revert the change in git and run the mysql command again.

If this sounds scary, you're pretty much going to need to go in and add these by hand...

Hi,

Thanks so much for both of your replies. That makes sense (mostly) and sounds like something we could tackle with about a month more experience than we have. I think we'll stick with doing it by hand, since it's not such a large collection, and we might be just competent enough to mess something up in the mysql database (and not enough to fix it).

Abigail

I completely understand the fear of messing up your active database. I highly, highly recommend setting up Omeka on a server specifically for messing around with the database, plug-ins, etc. I cannot overstate how much easier my life has been since I started doing things like find/replace in SQL via the command line. Especially with database backups and TRANSACTION ( http://dev.mysql.com/doc/refman/5.0/en/commit.html ), the danger is relatively small.