FindPagesWithCriteria works different in CMS 6 R2

I am currently upgrading a site to run under EPiServer CMS 6 R2

One thing that struck me was that I got zero results back when using code that earlier had been tested and worked.
The code below works fine in CMS 6.0:

DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criteria);

After the R2 upgrade that code yielded no results.

The solution is to add null as a parameter for language branch as this:

DataFactory.Instance.FindPagesWithCriteria(composerStartNode,criterias,null);

The null in this case means any language.

I had earlier run into another problem using PageType Builder and learned to add the extension method .AsTyped() if the code yielded no result when searching for typed pages.

To be totally confident that my code wont break I now have to create a search and replace with:

FindPagesWithCriteria(composerStartNode,criterias,null).AsTyped();

The big question is why the code broke after the R2 upgrade? I can’t find any documentation stating that you must enter null as language branch.

What changes have been made to the FindPagesWithCriteria method?

About these ads

About danbad
.net developer working with CMS

4 Responses to FindPagesWithCriteria works different in CMS 6 R2

  1. Tom Pipe says:

    EPiServer changed the way the event handler works, so it is impossible to modify the object during the event.

    The solution for now is to use the AsTyped() extension method as you found.

    Joel has more detailed information on his blog:

    http://joelabrahamsson.com/entry/pagedata-objects-not-returned-as-typed-when-using-page-type-builder-and-findpageswithcriteria

  2. danbad says:

    Tom, I am aware of that but the main problem is that the code stopped working without the null parameter, when I added the null parameter it worked as before. The AsTyped is added as a precaution.

  3. Aref says:

    Hi Danbad

    Can you please help me?

    We have EPiServer CMS 6 R2 along with EPiServer Commuity and Relate Plus. Also we have built an ASP.NET web site with a forum on top of it (the forum is using the community and relate APIs). There is a request that each forum topic and its replies have multiple file attachments (documents, images and videos). Since I am new to EpiServer, can someone please let me know how can I implement this?

    In my newtopic.aspx file I have some text boxes only that receives the subject, body and other details then creates an instance of ForumTopic entity and inserts it into the database.

    Thanks a lot
    Aref

  4. Pingback: Confluence: EPiServer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: