AI OnAI Off
When performing the search, you just need to locate what part of the tree structure you are inside, and filter the Ancestors-list by that:
.Filter(x => x.Ancestors().Match(a-b-or-f-page.ContentLink.ToReferenceWithoutVersion().ToString())
If a, b and f are landing pages of the same page type, you could do simething like this:
public static T GetParentOfType<T>(this ContentReference contentReference) where T : PageData
{
if (contentReference.IsNullOrEmpty())
return null;
while (contentReference != ContentReference.EmptyReference)
{
var content = contentReference.Get<PageData>();
if (content is T)
return content as T;
if (contentReference.Equals(ContentReference.StartPage))
return null;
if (content == null)
return null;
contentReference = content.ParentLink;
}
return null;
}
And then:
.Filter(x => x.Ancestors().Match(currentPage.GetParentOfType<MyLandingPage>().ContentLink.ToReferenceWithoutVersion().ToString())
Hi Tomas.
Thanks for your reply.
am getting below error.
the Ancestorsdoes not exist in the current context.
Ancestors() is an extensions method defined in the namespace EPiServer.Find.Cms.ContentExtensions
What version of Find are you using?
Hi,
i have a site with pages like this structure.
a
b
f
suppose if am browsing c page and i click serch button, then i want to display serch results under b level tree.dont want to display f tree level results.
suppose if am browsing g page and i click serch button, then i want to display serch results under f level tree.dont want to display b tree level results.
or
otehrwise is there any option to filter GetResult() after search hits.