November Happy Hour will be moved to Thursday December 5th.

Is It possible to specify the start page in the Epi Server CMS Find query instead of entire project search.

Vote:
 

Hi Team, I would like to get the all the pages start with alphabets letters(Title Start with A,B,C..Z) under specific parent page using Epi Server Cms find query. Can anybody familier same kind of functionality?. 

#195276
Jul 19, 2018 9:22
Vote:
 

Hello, After having a look, the query would look something like this:

internal Injected<IClient> FindClientService { get; set; }
var sitePages = FindClientService.Service.Search<PageData>()
    .Filter(page => page.ParentLink.Match(parentReference))
    .Filter(page => page.Name.PrefixCaseInsensitive("A") | page.Name.PrefixCaseInsensitive("b"))
    .OrderBy(page => page.Name)
    .GetContentResult();

You would send the reference for the parent page into the query and then you could then put the characters into the 2nd filter method in the PrefixCaseInsensitive method. The above example would return pages that are children of a specific page. The second filter would then return if any of the pages Name begins with A or B (no matter if they are uppercase or lowercase).

Hope this helps!

#195281
Edited, Jul 19, 2018 10:46
Vote:
 

Thank you for your quick response Steven, However i am able to get only 1'st root child pages and not able to get Child's Child pages(descendant) . Hope you understand.

#195284
Jul 19, 2018 11:23
Vote:
 

Ok, I get what you mean now. I shall have to have a look and see how to do that. Will get back to you if I can figure it out smile

#195287
Jul 19, 2018 11:31
Vote:
 

You may be able to use the Ancestors extensio to search where the ancestor is the page root. This has been discussed here:

https://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=177252

#195302
Jul 19, 2018 14:57
Vote:
 

Thank you David Knipe You saved my time today. Its perfectly working for Pages , But For Blocks also we need smile .

#195330
Jul 20, 2018 11:06
Vote:
 

Do you want to find blocks that are on pages or blocks where they are in the tree?

#195338
Jul 20, 2018 12:13
Vote:
 

Irrespective of all the down blocks in the tree(for given parent). Hope you understand.  

#195341
Jul 20, 2018 12:21
Vote:
 

If you are looking for blocks within certain places within the tree then the Ancestors method should could work, use the content reference of the folder that the block(s) sit in.

#195352
Jul 20, 2018 15:35
Vote:
 

Yes David Knipe Thanks again. Its similar but thing is i will pass the page content link  and needs to get the all blocks which is created using the block type(Specific document list block) in the same page and child pages as well.

I am trying to write below for blocks:

var client = SearchClient.Instance;
var query = client.Search<DocumentListBlock>()
// .Filter(x => x.Ancestors().Match(startPage.ToReferenceWithoutVersion().ToString())) ----- Need to get the used blocks under the specified start page 
.Filter(page => page.Title.PrefixCaseInsensitive("abc")).Take(1000);
var batch = query.GetContentResult();

I am not able to find the Ancestors method for blocks.

#195405
Jul 24, 2018 10:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.