1

I have now round about 20 custom content types developed. E.g. (planing, presentation, agenda, sample etc.).

Problem 1:

I want to save those content types into a refinable string, so I am able to get only those content types in an refinement panel.

I don't want to use SPContentType, because that contains all content types.

Should I handle that with a new result source which contains the content type ids?

Problem 2:

I want to be able to click in the refinement panel e.g. onto presentation and after that the other refiners are getting changed or I get redirected to a new searchresults page which sounds better to me...

The default refiners at /results.aspx could be:

  1. Content-Type

  2. Language

  3. Audience

If "presentation" is selected the refiners should be:

  1. Content-Type

  2. Language

  3. Responsible

  4. Author

  5. Audience

But I only want that to change if the content type presentation is selected. Only then the refiners Responsible and Author should be populated.

Does anyone know how to do that?

I guess there should be a search results page for each content type?

There the search results should be filterd for the content type?

If so, how do I configure the redirection:

If content type "presentation" at /results.aspx, then go to /presentations.aspx?

I guess I have to create my own display template for the refiner content type?

How to put in those links to the new search result page?

I know, a lot of "I guess", but I am not that good with search customization by now...

Hope it is clear, if not, please ask more in the comments.

4
  • I too am new to customising SharePoint search, so am interested in what suggestions others have for you. Could you look to use a client side solution for your customisation, e.g. use SharePoint's REST API to get search results and refiners? msdn.microsoft.com/en-us/library/office/jj163876.aspx
    – Submits
    Commented Apr 20, 2016 at 13:36
  • @Submits, I tried it, but it wasn't working as I expected. Everything worked fine, but if you want to pass the searchquery to the next searchpage it is quite difficult if you also have some other refiners
    – Patrick
    Commented Apr 21, 2016 at 6:09
  • Difficult in what way? Difficult != impossible :)
    – Submits
    Commented Apr 21, 2016 at 7:51
  • added some information as an answer. Maybe helps you.
    – Patrick
    Commented Apr 21, 2016 at 8:02

1 Answer 1

1

I will give here some steps I did:

I created my own refiner for the content types. I took the standard one and added the lines:

if (ctx.RefinementControl.propertyName == "SPContentType") 
        {                       
            var blacklist = [
                "Comment",
                "Element",
                "Document",
                "Folder",
                "Links",
                "Video",
                "DocumentSet"
            ];

        listData = listData.filter(function(item) {
            return blacklist.indexOf(item.RefinementValue) == -1;

        });
    }

So I only had the custom content types I wanted. (The blacklist was way longer).

That worked pretty well.

To pass the search query I used:

var kQuery = ctx.DataProvider.get_currentQueryState().k;    
    console.log(ctx);
    (function () {
    window.UrlQuery = (function () {
        var result = {
            hash: {},
            query: {}
        };

        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            result.query[pair[0]] = pair[1];
        }

        var hash = window.location.hash.substring(1);
        var hashVars = hash.split("&");
        for (var i = 0; i < hashVars.length; i++) {
            var pair = hashVars[i].split("=");
            if (pair.length > 1) {
                result.hash[pair[0]] = pair[1];
            }
        }

        return result;
    })();

But if you e.G. change the range of the results via an other refiner and change maybe some other refiners, after clicking the specific content type you don't get the expected search query.

An easy option is to first select the content type and then the customer has to type in the search query, but that's not what I wanted.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.