Hey,
I’m trying to include a custom JavaScript file for one specific site (the Omeka instance has multiple sites). For now I have site x using the default theme; I used the way that themes work to include a custom JavaScript solution. However this option is not durable. An update to the themes or Omeka S would render this ‘hackish solution’ obsolete. The JavaScript code changes the appearance and target of URI’s when viewing an item publicaly. This is the code:
$(document).ready(function(){
var uris = document.getElementsByClassName("uri-value-link");
for (var x = 0; x < uris.length; x++){
uris[x].text = "🔗 "+uris[x].text;
uris[x].setAttribute("target","_blank");
uris[x].style.color = "rgb(211,56,0)";
uris[x].style.textDecoration = "underline";
//console.log(uris[x]);
}
});
I put it in a separate file called include.js
. This file is stored in /themes/default/asset/js
. I added it to the head
of my item-pages by adding: $this->headScript()->prependFile($this->assetUrl('js/include.js')); // include custom script
to /themes/default/view/layout.phtml
.
There are some obvious problems with this pseudo-solution:
- Every site using the Default theme that has the same class on a page will be affected, whereas I want a more granular control (i.e. only affect one site of the entire Omeka instance)
- Updates to the theme will render the changes in
themes/default/view/layout.phtml
back to the default. I.e. After every style-update someone needs to make that change. I only work on the project as a temporary resource, so it has to be an easier solution than this (especially if one day the way themes work get a big redesign)
With all this said and done, my question is simple, but my search for a answer has been without results:
Is there a durable way to include custom JavaScript solutions for a specific site in Omeka S?