Copied to clipboard

Flag this post as spam?

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


  • Stefan Joseph 19 posts 120 karma points
    Mar 08, 2018 @ 16:24
    Stefan Joseph
    0

    How to check if a macro has been picked

    I have a section of a template that I only want displayed if a Macro has been picked.

    <div class="banner dark">
    <div class="container">
        <ul class="statistics flex">
            @Umbraco.Field("productStatistic")
        </ul>
    </div>
    

    So essentially an If statement wrapped around this along the lines of:

    IF a productStatistic macro has been selected - display this banner.

    Can anyone help me with this? Thanks in advance!

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Mar 09, 2018 @ 07:56
    Michaël Vanbrabandt
    0

    Hi Stefan,

    why not just add a property boolean which you pass into the macro?

    Then you could create a param showTemplate and do a check on this in order to show/hide the actual html?

    You can read more about macro's with parameters in the docs: https://our.umbraco.org/documentation/reference/templating/macros/#rendering-macros-with-parameters

    Hope this helps!

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Mar 12, 2018 @ 15:52
    Michaël Vanbrabandt
    0

    Hi Stefan,

    did you solve your issue?

    Can you share it with the community? Thanks!

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft