The Store pages contain a multinode treepicker where the managers can select the services that are available in their specific stores. My template generates a nice list of available services. No problem so far.
Now, on the Service pages I need to generate a list of stores that offer the specific service, i.e. Store pages where the current Service page is selected with the multinode treepicker.
I could really use some suggestions on how to go about this.
I would do an examine query to search for the udi value of the current node. I would make the examine query search the property alias of the multi node tree picker for the udi value from the current node.
Here is an extension for getting the udi for the current page which is safe to query in examine:
public static string SafeUdi(this IPublishedContent contentItem, string udiType = "document")
{
var udi = new GuidUdi(udiType, contentItem.GetKey());
return udi.ToString().Replace(":", "\\:");
}
So build up your examine query and pass in contentItem.SafeUdi() as your search term.
Something like this:
var searchTerm = Model.Content.SafeUdi();
var searcher = index.GetSearcher();
var results = searcher.CreateQuery("content").NodeTypeAlias("store").And().Field("services", searchTerm).Execute();
Here is a link to the examine documentation quick start:
Which nodes have picked the current node?
Hola Umbracos
I have two page types, Store and Service.
The Store pages contain a multinode treepicker where the managers can select the services that are available in their specific stores. My template generates a nice list of available services. No problem so far.
Now, on the Service pages I need to generate a list of stores that offer the specific service, i.e. Store pages where the current Service page is selected with the multinode treepicker.
I could really use some suggestions on how to go about this.
Best
Hi Jesper
I would do an examine query to search for the udi value of the current node. I would make the examine query search the property alias of the multi node tree picker for the udi value from the current node.
Here is an extension for getting the udi for the current page which is safe to query in examine:
So build up your examine query and pass in contentItem.SafeUdi() as your search term.
Something like this:
Here is a link to the examine documentation quick start:
https://our.umbraco.com/documentation/reference/searching/examine/quick-start/
Cheers
Paul
Hi Jesper,
Paul example is perfect but just thought an alternative simple approach.
var listStores = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf("store");
var selectedStores = new List
foreach (var s in listStores) { if (s.Services.Any(x=>x.Id == CurrentPage.Id)) { selectedStores.Add(s); } }
Cheers,
Shaishav
Thanks for inputs. I found this solution https://our.umbraco.com/forum/using-umbraco-and-getting-started/100671-is-my-item-on-my-list
is working on a reply...