Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
I'm just going to take a guess on what you want --
To get a page by PageName, you'll need to do a FindPagesByCriteria search for it. This isn't ideal, as PageName is not unique, so make sure you have the one you want.
Once you get that page, do this to get its children:
PageDataCollection childPages = DataFactory.Instance.GetChildren(parentPage.PageLink);
When you run FindPagesWithCriteria it returns a PageDataCollection. The parentPage in Deane's example is one of the pages in that collection, the one you consider to be the match. The FindPages call could look something like this
var pageNameToFind = "Test";
var matches = DataFactory.Instance.FindPagesWithCriteria(
PageReference.StartPage,
new PropertyCriteriaCollection()
{
new PropertyCriteria()
{
Condition = EPiServer.Filters.CompareCondition.Equal,
Name = "PageName",
Required = true,
Type = PropertyDataType.String,
Value = pageNameToFind
}
});
Hi,
Thanks for the reply. Can we search the page if we have only PageTypes. like With this creteria I got all the subpage under ther page name "Test" and I want page having pagetype "test Contact" .
Hi,
Thanks for the reply.
In the above patch of code given by Magnus if i want to get childrens.
PageDataCollection childPages = DataFactory.Instance.GetChildren(matches.PageLink);
Is this is the right way. what should be "matches.PageLink" ???
matches is going to be a PageDataCollection. Remember that PageName isn't unique, so you could get back one page or a hundred.
matches is a collection of PageData objects, so to get the children of the first one:
PageDataCollection childPages = DataFactory.Instance.GetChildren(matches[0].PageLink);
Hi,
Thanks for the reply and if i want page among all the childrens having pagetype "contact" .
then I am adding again cretaria in all the subpages.
var contact = DataFactory.Instance.FindPagesWithCriteria(
PageReference.StartPage,
new PropertyCriteriaCollection()
{
new PropertyCriteria()
{
Condition = EPiServer.Filters.CompareCondition.Equal,
Name = "PageTypeValue",
Required = true,
Type = PropertyDataType.String,
Value = contact
}
});
in that case whaqt should be the PageReference.StartPage , childPages??
You can use multiple criteria in the same query, like so:
var pageNameToFind = "Test";
var pageTypeIdToFind = 2;
var matches = DataFactory.Instance.FindPagesWithCriteria(
PageReference.StartPage,
new PropertyCriteriaCollection()
{
new PropertyCriteria()
{
Condition = EPiServer.Filters.CompareCondition.Equal,
Name = "PageName",
Required = true,
Type = PropertyDataType.String,
Value = pageNameToFind
},
new PropertyCriteria()
{
Condition = EPiServer.Filters.CompareCondition.Equal,
Name = "PageTypeID",
Required = true,
Type = PropertyDataType.PageType,
Value = pageTypeIdToFind.ToString()
}
});
PageReference.StartPage in the FindPagesWithCriteria call indicates where in the pagetree to start the search.
You can find most of this information at http://sdk.episerver.com (both class reference and useful howtos in the developers guide section) and the documents section here at World: http://world.episerver.com/Documentation/
Hi,
Thanks for the reply .I want two property one from Page A and other from the one of children of A
I am doing loop that is:
foreach (PageData startPage in DataFactory.Instance.GetChildren(matches[0].PageLink))
{
if (startPage.PageTypeName == "contact")
{
}
Can I get the properties of the page having startPage.PageTypeName == "contact"?
Ah, I misunderstood. If you want to find something in the direct children of the page, looping through them like you do is probably better than doing a second FindPages... unless there are many child pages. So your loop should find the child pages with page type named "contact", and you can then just read properties from that page (startPage["MainBody"] etc.).
Hi,
thanks for the reply. just like startPage["mainBody"] can we retrieve the values from matches[0], the page we get from serchbycreteria.?
Of course, they're all PageDatas. Intellisense should help you see that and what else you can do and not.
Intellisense and a check in the sdk should help:
How to get Descent pages on basis of parent Page Name