Tech Blog

Move Certain facet values to top of facet list

In our Primo, we need certain resource type facet values (books, e-books, journals, e-journals) to be always on top of the facet list, no matter how high the number of expected results is. In the old UI, this was accomplished by dom manipulation via jQuery.

Since we cannot use jQuery with the new UI anymore, I searched for a way to move up the facets via angularjs.

This is my solution – add the following code to the custom.js file in the js folder of your custom Primo package:

app.component('prmFacetExactAfter', {
        template: '<span ng-controller="FacetExactAfterCtrl"></span>'

app.controller('FacetExactAfterCtrl', function ($scope) {

    var facetGroup = $scope.$parent.$parent.$ctrl.facetGroup;

    function moveToTop(topFacets)
        var topFacetObjects = [];

        angular.forEach(facetGroup.values, function(facet, index) {
            if(topFacets.indexOf(facet.value) != -1)

        topFacetObjects.forEach( function(facet, index) {
            facetGroup.values.sort(function(x,y){ return x == facet ? -1 : y == facet ? 1 : 0; });

    if( == "rtype")
        facetGroup.displayedCount = 8;

        var topFacets = [ "journals", "printjournals", "books", "printbooks" ];

Here the number of displayed resource type facets is set to 8. The top facets are moved to the top and ordered among each other according to the number of expected results.

Of course this controller can also be used for the other facet types.

Best regards

Lars Heuer

University Library, Oldenburg, Germany


Leave a Reply