ISearchableTree with Konstrukt urls
# help-with-umbraco
o
I’m using konstrukt for the first time. Amazing package to be honest. However, now I want to give my users the ability to search for custom collections in the main Backoffice Search functionality. I’ve been able to do it using the ISearchableTree but the results generate an edit url that doesn’t match the konstrukt ones. The default pattern in Umbraco is something like: [sectionAlias]/[treeAlias]/edit/[entityId] And the one generated by konstrukt: [sectionAlias]/konstrukt/edit/[collectionName]![entityId] I can’t find a way to customize that using the SearchResult that we have to use in this case 🙄
Hey @Matt Brailsford (HQ) , I’m sorry for the tagging, but no one seems to had this requirement and in my opinion it is important give my users the ability to search all their collections globally in BO. Is there any solution for this that I’m not aware of?
m
Hmm, it's not something I've looked at to be honest so probably hasn't been thoroughly tested as a use case. A quick search through the codebase though suggests it's possible but you may need to implement a custom angular
searchResultFormatter
. You can see the default one here https://github.com/umbraco/Umbraco-CMS/blob/6e154e0a0f63bb0f8c742f15c4f2c718b9515b16/src/Umbraco.Web.UI.Client/src/common/services/searchresultformatter.service.js#L4 You can write your own and register them with angular, then I believe the
ISearchableTree
returns a
TreeSearchResult
which has a
JsFormatter
property which you can set to override the default search result formatter. https://github.com/umbraco/Umbraco-CMS/blob/6e154e0a0f63bb0f8c742f15c4f2c718b9515b16/src/Umbraco.Core/Models/ContentEditing/TreeSearchResult.cs#L21 I think it should be a case of giving the custom formatters name and angular will automatically resolve it. Hopefully that should be enough to get things working for you.
I've created a feature request to add this OOTB but I think a custom implementation should work for you for now without a problem https://github.com/outfielddigital/konstrukt/discussions/64
o
I'll give it a try. Thanks for the tip Matt.
@User, unfortunately that didn't work. ISearchableTree SearchAsync method returns Task, not a TreeSearchResult
I can't connect the results with my custom formatter
3 Views