Is it possible to get a Page using PageName?
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.
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!
@Deane Darn you beat me to it by 6 minutes ;)!
Yes, but your answer was much more complete, so...
Battle of the New EVMPs-----------------------------David: 1Deane: 0
Superb, thanks guys!