Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Wulff Nielsen 11 posts 74 karma points
    Mar 13, 2012 @ 08:58
    Michael Wulff Nielsen
    0

    Create database driven pages in Umbraco 5

    I am trying to use a database to deliver content to an umbraco site. In this example there is a db table containing Live-events.

    What I would like to build is this structure:

    1. /Events - (List all active events from a database)
    2. /Events/Details/1 - (details for event with id 1)

    As you can see the structure is a classic MVC way of doing this.

    The first solution I came up with involved doing the following:

    1. Create a SurfaceController with an Index method and a Details method
    2. Define two child action macros to call the functions from 1.
    3. Create two umbraco pages (/Events and a details childpage) and inserted the macros onto the pages.

    Here you can see the function definitions:

            [ChildActionOnly]
            public PartialViewResult Index()
            [ChildActionOnly]
            public PartialViewResult Details(string guid)

    The index page works fine, but the details macro never gets called with a parameter. Apparently Umbraco isn't smart enough to route parameters to macros inside pages.

    So my questions are:

    1. Is this the correct way to build database based content into the umbraco frontend?
    2. If not, then what is the preferred way in Umbraco 5?
    3. Does any sample code exist for this scenario?

    If you need more information please don't hesitate to ask.

    Thanks in advance

    Michael Wulff

Please Sign in or register to post replies

Write your reply to:

Draft