Copied to clipboard

Flag this post as spam?

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


  • Dave Shipston 21 posts 113 karma points
    Mar 21, 2016 @ 12:29
    Dave Shipston
    0

    How to use macros to define side menus

    Hi,

    I'm new to Umbraco, so a little clueless, so please bear with me.

    I'm building a site where the content editors want to be able to manually specify which side menu gets displayed on new pages as they create them.

    Now I'm happy with how you can 'hook' a partial view macro file into a template, so I was planning to have each (static) side menu as one of these.

    In my Data Type of "content page", I can add a tab and call it "Select Side Menu" and then add an editor type of Macro Container. This all looks good so far as I can specify all of the side menu partial views as a dropdown list.

    My problem is that I've no idea what code to add to my template in order to display the selected side menu.

    Obviously I might be approaching all of this wrong but if I am on the right lines, can anyone help me finish this off please?

    thanks

    Dave

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 21, 2016 @ 13:19
    Dennis Adolfi
    100

    Hi Dave.

    If you mean that you have a Document Type called "Content page" and it has a property called "Select Side Menu" of datatype "Marco Container", and you want to render the macro html in your template, you can write this:

    @Html.Raw(CurrentPage.SelectSideMenu)
    
  • Dave Shipston 21 posts 113 karma points
    Mar 22, 2016 @ 09:32
    Dave Shipston
    1

    Thanks Dennis, that's exactly what I meant and it worked a treat!

    I do tend to struggle with knowing/finding these snippets of code.

    Much appreciated

    Dave

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 22, 2016 @ 09:47
    Dennis Adolfi
    0

    Awsome Dave, happy that i could be of help! Good luck with the rest of the site! :)

Please Sign in or register to post replies

Write your reply to:

Draft