Skip to main content
ExLibris

 

  • Subscribe by RSS
  • Ex Libris Knowledge Center

    Primo Backoffice Bookmarklets

    Created By: Gabriele Höfler
    Created on: 10/02/2020



    If you have not come across SvG's immensely helpful article on bookmarklets for the Primo Frontend, be sure to also check it out. It explains, among other things, how to set up a bookmarklet.

    Change Order of Listed Entries

    Views Wizard - Change Order of Material Type in Advanced Search's Dropdown

    Changing material types and the order in which they appear in the dropdown menu can be a tedious type of work. A colleague likes to pantomime the use of a ruler against the screen when talking about it, because it is hard to track the label of a line and its corresponding arrows to move material types up and down. This is where the setting can be made:

    Views Wizard > Tiles Configuration > Advanced Search > Material Type

    Another way to move those entries up and down is making use of a bookmarklet.

    Bookmarklet

    If you had a material type with the label "Films", these are the bookmarklets you could use to move entries up and down:

    "Films" up

    javascript:(function() {document.getElementById('Films-up').click()})();

    "Films" down

    javascript:(function() {document.getElementById('Films-down').click()})();

    Note: I did not extensively test this bookmarklet on labels that have special characters and/or spaces in them. Especially spaces might have the side effect of moving more than the line you intend to. So use with caution and keep an eye on the order of the material types you want to display!

    How it Works

    All Arrows on the far right end of the screen have their own ID in HTML. They are comprised of the material type's label and the suffix "-up" and "-down". All the bookmarklet does, is click the elements with that ID.

    Views Wizard - Change Order of Values Listed in Full Display of Full Results

    In the back office, this looks exactly like the list in the Screenshot above, but the HTML does not look at all the same. So if you want to make changes here:

    Views Wizard > Tiles > Full Display > Full Results

    You will need an entirely different bookmarklet to do the same thing.

    Bookmarklet

    If you had a Full Display label named "Edition", this is the bookmarklet you could use to move it up:

    "Edition" up

    javascript:(function() {
        var labelTextSearchedFor = 'Edition';
        var labels = document.getElementsByTagName('label');
        var alertMissing = true;
        for (var i = 0; i < labels.length; i++) {
          var label_id = labels[i].id;
          var label_text = labels[i].textContent;
          if (label_text == labelTextSearchedFor && label_id) {
            var field_number = label_id.match(/^fieldDesc-(\d+)-\d/);
            var alertMissing = false;
            setActionAndSubmit('up '+field_number[1]);
            return false;
          }
          label_id = null;
          label_text = null;
        }
        if (alertMissing) {
          alert('Could not find Element with label ' + labelTextSearchedFor);
        }
    })();

    If you want to use it on other labels, you will need to set the Value "labelTextSearchedFor". If you want to move something down instead of up, change the line where "setActionAndSubmit" is called, by just replacing "up" with down". Mind the blank after the word, though!

    Note: Please be very careful when using bookmarklets in the back office! Make sure they make only the changes you intend them to do!

    How it Works

    Looking at the HTML one can see that for the up and down actions there is a specific javaScript-function called to make the change. The bookmarklet just calls the very same function.




    • Was this article helpful?