Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John Churchley 272 posts 1258 karma points c-trib
    Oct 12, 2018 @ 08:46
    John Churchley
    0

    Custom Section Search

    Hi all,

    I'm trying to use an interceptor to populate my own search results in a custom section. I've registered it in my app package.manifest.

    angular.module('umbraco').service('SearchInterceptor', function () {
        var service = this;
    
        service.request = function (request) {
            if (request.url == "/umbraco/backoffice/UmbracoApi/Entity/SearchAll") {
                alert("Hello");
            }
    
            return request;
        };
    });
    
    angular.module('umbraco').config(function ($httpProvider) {
        $httpProvider.interceptors.push('SearchInterceptor');
    });
    

    Anyone any ideas?

  • John Churchley 272 posts 1258 karma points c-trib
    Oct 12, 2018 @ 08:58
    John Churchley
    100

    Answer

    angular.module('umbraco').service('SearchInterceptor', function () {
        var service = this;
    
        service.request = function (request) {
            if (request.url.indexOf("/umbraco/backoffice/UmbracoApi/Entity/SearchAll")!== -1) {
                alert("Hello");
            }
    
            return request;
        };
    });
    
    angular.module('umbraco').config(function ($httpProvider) {
        $httpProvider.interceptors.push('SearchInterceptor');
    });
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 12, 2018 @ 09:00
    Dave Woestenborghs
    1

    Hi John,

    You probably need to implement an ISearchableTree (https://our.umbraco.com/apidocs/csharp/api/Umbraco.Web.Search.ISearchableTree.html)

    Some more info can also be found in this issue : https://issues.umbraco.org/issue/U4-2676

    But I must say I haven't tried it yet.

    Dave

  • John Churchley 272 posts 1258 karma points c-trib
    Oct 12, 2018 @ 13:46
    John Churchley
    0

    Thanks Dave,

    I've gone in that direction but hit the obstacle how to using ISearchableTree with my own results.

    Created a separate post https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/94152-how-to-use-isearchabletree-for-custom-section-search

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies