Copied to clipboard

Flag this post as spam?

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


  • Mr A 216 posts 278 karma points
    Aug 17, 2011 @ 18:44
    Mr A
    0

    Using Razor in Umbraco to display number of products

    I am using Razor on Umbraco to built a cms website , I have created static pages easily on umbraco , I am having difficulty in creating products sections, as products section will be manage by the client, Product section will have sub products for instance books, accessories. When the user clicks on book section , all the books should be displayed vice versa. Can anyone help me in creating the document types and how to structure the content so that the client can easily add items to the products in content section. And the system should display all the items of that product on the website.

    Any example or suggestion will be highly appreciated.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 18, 2011 @ 17:12
    Dan Diplo
    0

    You basically need three types of document type - a Product Section, a Product Category and a Product.

    The Product Section should list all the Product Category pages in the section. The Product Category page should list every product in the category. The Product page should display the indvidual product details. Your client can then add products to a category (and categories to a section).

    You would nest this something like:

    Home
    -- Section 1
    ----- Category 1
    ------- Product A
    ------- Product B
    ------- Product C
    ------- Product D
    ----- Category 2
    ------- Product X
    ------- Product Y
    ------- Product Z
    -- Section 2
    ---- Category 3
    ------ Product J
    ------ Product K
    ------ Product L
    ---- Category 4
    ... etc.
    

    You can generate a list of child pages very easily in Umbraco, which can be used as the basis of the Section and Category listing pages. Something like:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @{
        <ul>
        @foreach (var item in Model.Children)
        {
            <li>
                <a href="@item.Url">@item.Name</a>
            </li>
        }
        </ul>                    
    }
Please Sign in or register to post replies

Write your reply to:

Draft