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

Vote:
 

Is it possible to get a Page using PageName?

#45151
Nov 01, 2010 18:22
Vote:
 

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.

#45152
Nov 01, 2010 18:59
Vote:
 

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)"
            };

            criterias.Add(propCriteria);

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

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

#45153
Nov 01, 2010 19:05
Vote:
 

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

#45154
Nov 01, 2010 19:06
Vote:
 

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

Battle of the New EVMPs
-----------------------------
David: 1
Deane: 0

#45155
Nov 01, 2010 19:10
Vote:
 

Superb, thanks guys!

#45172
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.