Find pages by URLSegment

Member since: 2007

I´ve done some testings, but with no success. Is it possible to search by URLSegment?

PropertyCriteria criteria = new PropertyCriteria();
criteria.Condition = EPiServer.Filters.CompareCondition.Equal;
criteria.Name = "URLSegment";
criteria.Type = PropertyDataType.String;
criteria.Value = "test";

PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
criterias.Add(criteria);

 

 

 

#29174 Apr 14, 2009 11:04
  • Member since: 2005

    Hi!

    I've not tested it, but try using the following instead:

    criteria.Name = "PageURLSegment"

    All built in properties are prefixed with "Page".

    Regards

    Per Gunsarfs
    EPiServer CMS Development team

     

    #29177 Apr 14, 2009 11:42
  • Member since: 2007
    Doesn´t work. But now it returns all pages instead so something happens.
    PropertyCriteria criteria = new PropertyCriteria();
    criteria.Condition = EPiServer.Filters.CompareCondition.Equal;
    criteria.Name = "PageURLSegment";
    criteria.Type = PropertyDataType.String;
    criteria.Value = "test";
    criteria.Required = true;

    Is there another way to achieve this? I´m building a cross publishing plugin and a custom url rewriter.
    So the page can have more than one url, e.g. example.com/archive/test/ (original url) and example.com/another-page/archive/test/ (custom url).
    My problem is to convert the second url to an internal address. Now I´m truncating the second url to example.com/another-page/archive/ (the archive page exists on this url) and then try to find tha page "test" under example.com/archive/ and convert it to /templates/archive.aspx?id=1&articleId=2.
    Today I´m using the method ConvertToInternal() to find the page using the orginal url to the archive where the page is published to and then add the url segment. But that doesn´t work if the we have another structure under  example.com/archive/ than a flat structure, e.g. example.com/archive/2008/01/test/. 
    #29181 Apr 14, 2009 13:42
  • Member since: 2007
    Solved it by adding the same structure to both url's. E.g. exampel.com/archive/2008/01/test/ and exampel.com/another-page/archive/2008/01/test/.
    #29187 Apr 14, 2009 16:01