Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Get a page by PageName


Is it possible to get a Page using PageName?

Nov 01, 2010 18:22

The only way I can think of is to do a FindPageByCriteria and search the PageName property.  Be aware, however, that PageName's aren't unique, so you could get more than one.

Nov 01, 2010 18:59

Hello Peter this is certainly possible. Using FindPagesWithCriteria. However if there is more than one page with the same name in your site (e.g. 2 pages called "news" in different sections of the site) then you can expect to get different results:

            PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
            PropertyCriteria propCriteria = new PropertyCriteria
                Name = "PageName",
                Type = PropertyDataType.String,
                Condition = EPiServer.Filters.CompareCondition.Equal,
                Value = "Your page name (e.g. News)"


            PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);

Remember that FindPagesWithCriteria does not cache and goes straight to the database so use it carefully!

Nov 01, 2010 19:05

@Deane Darn you beat me to it by 6 minutes ;)!

Nov 01, 2010 19:06

Yes, but your answer was much more complete, so...

Battle of the New EVMPs
David: 1
Deane: 0

Nov 01, 2010 19:10

Superb, thanks guys!

Nov 02, 2010 9:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.