hacking on ContentDM links in display metadata

I'm procrastinating some household chores, so I'll try and keep this short.

We have ContentDM (CDM) where I work.

CDM is a power tool to say the least. There are a lot of positives and a lot of negatives. On the surface, to the ignorant, it's just a display tool but to the less ignorant there's obviously a lot going on under the hood.

Anyway, one thing I don't like is how CDM hyperlinks pretty much every non-article/non-preposition word in certain fields (Title, Description being the most annoying). These relative links lead to a search for that word in CDM, but I think it makes the text very hard to read. Additionally, I don't see the value add to linking to a search for one word. It's misleading, too, when two adjacent words are individually hyperlinked because it appears that those two words, as a phrase, are linked.

Besides that, links in given fields (Subject, Date, etc.) that lead to searches for those values might be better if against that given field only, etc. That's to say that while I like how one can click on a subject value and search CDM for that term, I think it's more effective to search against just the Subject field in that instance. It's debatable, true, but in the end having the ability to decide for oneself is what matters.

I can't see that one can control – per field – whether or not to remove the hyperlinks for each word in that field or control all the search parameters per field (which field to search, how to rank results, whether to use a phrase search or an "AND" or "OR" separated search, etc.).

I would be great if that level of customization was built in, but I can't see that it is. If I'm wrong, please let me know.

At least CDM lets you drop in your own JavaScript though.

While we haven't deployed it, I've got a near-ready JavaScript thingy that allows one to remove, per collection, hyperlinks in a given set of fields or to alter the link structure for links you want to keep in a given field.

The code still needs work and we still need to meet at my place of work to decide what fields to remove links from and which ones to alter – and which collections to apply what rules to, etc. So we're not deploying it just yet nor would I share the code until it's more solid.

But here's a screen shot of a page on our site before applying the JS code.

And here's an "after" screenshot.

In the "after" screenshot, the links in the Title, Description, and Physical Characteristics fields have been purged and links in certain fields have been altered.

In both screen shots, my mouse was hovering over the Subject value "Public libraries–North Carolina" and the hyperlink was originally "/cdm/search/searchterm/Public%20libraries–North%20Carolina/mode/exact". It was an exact phrase search, across all fields, for "Public libraries–North Carolina".

After running the script, the link was changed to "/cdm/search/searchterm/Public%20libraries–North%20Carolina/mode/exact/field/subjec/&clicked=true". Now, it's an exact phrase search just against the "Subject" field. A parameter of "&clicked=true" was also added. Perhaps we could use something like that for analytics, for tracking who's clicking on hyperlinks in the metadata.

By the way, I really hate these path-based approaches to field/value pairs in URLs. I'd rather see "&mode=exact" rather than "mode/exact". But I digress …

Anyway, this is a lousy post that needs to be explained better.

Like I said, it's too early to share the code but below is that part of the code that makes it run so one can see what rules were applied and how they're notated.

I should add that simply doing this with jQuery is the most straightforwad path if one just wanted to create some rules for their own CDM instance but I want to be able to share this with others and make it simple for them to configure the rules for their own CDM instance. And I had my own rule: no jQuery allowed in my code.

I did search around to see if this kind of thing was out there. And while I'm sure there are a few places doing this kind of thing to clean up their links, I couldn't find a JS library that could be applied to any CDM instance. If there is something out there, let me know please.

Anyway, here's the snippet that builds and runs the rules:

var begin = new Date().getMilliseconds(); // for timing purposes.
var cdmlh = new CDMLinkHack([ // process these collections.
                              'p16062coll21', these specific collections. */
                              //'p24', // all collections starting with "p24".
                              '' // all collections.
                            [ // purge relative hyperlinks from text in fields with these "id"s.
                            [ // alter hyperlinks in fields with these "id"s.
                              ['metadata_dated', {'field':'date'}],
                              ['metadata_object_date', {'field':'date'}],
                              ['metadata_object_dated', {'field':'date'}],
                              ['metadata_format', {'field':'formatb'}],
                              ['metadata_langua', {'field':'langua'}],
                              ['metadata_publia', {'mode':'any', 'field':'formatb', 'order':'nosort'}],
                              ['metadata_subjec', {'field':'subjec','&clicked=true':null}],
                              ['metadata_type', {'field':'type'}],
var end = new Date().getMilliseconds();
var elapsed = end - begin;
console.log("CDMLinkHack took " + elapsed.toString() + ' milliseconds to complete.');

// $ cdmlh.purgeLink('metadata_title'); // removes links from "metadata_title" field.
// $ cdmlh.alterLink('metadata_dated', {'field':'date'}) // force search against "date" field only.

Related Content:

Leave a Comment

Your email address will not be published. Required fields are marked *