Web Developer, Software Engineer and Mixed Language Artist
RSS icon Email icon Home icon
  • EPiServer – Unpublished page custom properties

    Posted on March 25th, 2010 Jamie No comments

    One of the things I recently discovered about our EPiServer configuration is that quite often we have pages associated with our current page, that haven’t yet been published.

    An example of this is when we have a Press Release and other associated press releases that show up in a side bar.

    For live, this is fine because we don’t want unpublished items showing up in the list however in edit mode, our content team need to see that the items they’ve associated, work as expected.

    The error that we’ve encountered is in edit mode, for each associated press release, if the press release was unpublished we weren’t getting the custom properties for that page (in code), even though the rest of the page object was as expected.

    The reason for this is that EPiServer only seems to bring back the custom properties for pages that have been published.

    So how do we go about obtaining a full page object for pages which are yet to be published?

    This is how we did it:

    ?View Code CSHARP
    // If the page is not yet published.
    if (page.PendingPublish)
    {
        // Check if we're in edit mode
        SystemPageBase basePage = Page as SystemPageBase;
        if (basePage != null)
        {
             PageReference reference = new PageReference(pageId);
     
             // Get the individual Master Language Branch based on the reference above.
             PageVersion pageVersion =  PageVersion.List(reference)
                             .Where(m => m.IsMasterLanguageBranch).FirstOrDefault();
             if (pageVersion != null)
             {
                  page = DataFactory.Instance.GetPage(pageVersion.ID);
             }
        }
    }

    As a side-note, this also alerted us to the fact that page IDs in EPiServer are not always of type Int32. Usually when an Id comes back from EPiServer we can parse it as an int however the IDs that come back from page versions, actually include an underscore (i.e. they’re strings).

  • Mmm…Mattessons

    Posted on March 15th, 2010 Jamie No comments

    Mattessons

    Today is the day… Two fast (and sausages filled) weeks later and we’re ready for the launch of the new Mattessons website.

    Our deadline for this project was determined by a new TV ad that’s coming out today and so the flexibility in timings was somewhat limited.

    We decided to use Wordpress for this project which means this is also my first commercial project on the WAMP stack. The decision to go with Wordpress was based on a few different criteria, the first being…time.

    Anyone who’s been working with Wordpress for any period of time will know how fast it can be to get a site up and running in no time at all. The time investment comes when you’re developing a complete custom template…enter Mattessons!

    As the lead developer on the Mattessons project I had to make some calls as to what amount of content management we were going to be offering to our client. The more they were able to manage, the longer it’d take in the development process. My decisions mostly revolved around the idea of “Lets do what we can to give them control over all content items”.

    We did this by employing some nice use of custom fields, the creation of a very basic custom markup language for inserting custom property values into page copy and by creating a system where pages themselves can be pulled into other pages and displayed as promos/previews.

    You’ll notice on the homepage of the new website that there are currently two promos being displayed. These promos are pages in themselves, just as are the products in the Our Range section and the footer items.

    Wordpress makes it really easy to get information about the current page and it’s child pages which enabled us to create a basic yet powerful hierarchy of products and product ranges. We’re also using a great plugin for relating pages to one another in a more lateral way. This again is being used in a slightly different way than standard by pulling out information on related pages and then obtaining those page details through the standard Wordpress API.

    All-in-all this has been a really fun project to work on. It’s been fast paced with a quick turn around and it’s been a joy working with a talented team of managers, designers, QAs and front end developers.

    What can I say… “It’s a Primal Thing”.