Optimizely CMS - Learning by Doing: EP07 - Create Controller/View for Pages

 


Episode 7 is Live!!

The latest installment of my Learning by Doing: Build Series on Optimizely CMS 12 is now available on YouTube!

This video demonstrates how to create controllers and views for various page types within Optimizely CMS 12, focusing on a fictional website called TasteTrail.

Here's a summary of the key steps:

  • Recipe Listing Page

    • New RecipeListingPageController created, extending PageController with the RecipeListingPage model.

    • View: index.cshtml under Views/RecipeListingPage.

    • Displays page title and iterates through child recipe pages, showing links and images.

    • Includes a null check to show “No recipes” if none exist.

    Recipe Page

    • Existing RecipePageController passes RecipePage model to the view.

    • View: index.cshtml displays page name and description.

    • Uses Html.Property to render ingredient and step blocks, with null checks for safety.

    Homepage

    • StartPageController passes StartPage model to the view.

    • View: index.cshtml shows site title and description only.

    Standard Page

    • New StandardPageController created, extending PageController with the StandardPage model.

    • View: index.cshtml under Views/StandardPage.

    • Displays page name and renders MainBody content using Html.Raw.

    • Uses a Property to render content from MainContentArea, supporting nested blocks.



Comments