Copied to clipboard

Flag this post as spam?

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


  • Bill Smith 52 posts 222 karma points
    Mar 20, 2013 @ 22:22
    Bill Smith
    0

    Hiding content

    I would like a content editor to choose whether some content appears on a page or not. I have used a checkbox but I don't know how to use that to determine whether content is visible not.

    Bill

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 20, 2013 @ 23:17
    Tom Fulton
    0

    Hi Bill,

    It depends on what you're using for templates/macros.  You could use an XSLT macro for this:

    <xsl:if test="$currentPage/showSomeContent = '1'">
      <xsl:value-of select="$currentPage/someContent" />
    </xsl:if> 

    If you're using Mvc Views for templates, you could do this right in the temlplate with something like this:

    @if (Model.Content.GetPropertyValue<bool>("showSomeContent")) {
      @Umbraco.Field("someContent")
    }

    (note, you need this at the top of your View for GetPropertyValue<bool> to work:  @using Umbraco.Web)

    Hope this helps,
    Tom 

  • Bill Smith 52 posts 222 karma points
    Mar 21, 2013 @ 10:56
    Bill Smith
    0

    Thanks Tom, would I create the XSLT macro and drop it into the content from the content editor?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 21, 2013 @ 18:08
    Tom Fulton
    0

    Ah, so you want to show pieces of content from only one field like an RTE?  That could get tricky, but yes, you could use a macro for that as well.  The question is where the user defines the "hidden" content - normally you could use a macro parameter, but RTE isn't a supported parameter type.  So you might have to define the hidden content elsewhere and use a Content Picker parameter where you can choose the node.  It might be best to use a separate field for the "Hidden content" if possible, then just drop the macro on your template.

  • Bill Smith 52 posts 222 karma points
    Mar 21, 2013 @ 19:48
    Bill Smith
    0

    Tom, the web page shows the latest 2 tweets and the client wishes to have the option to display the tweets or not. I have created a page that accepts a title (text string) and a URL to the tweet (multi line text) and the checkbox. Is it not possible to check the staus of the check box and display (or not) the contents of the text  boxes? 

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 21, 2013 @ 23:44
    Tom Fulton
    0

    Hi Bill,

    Yep, that should be easy.  What version of Umbraco are you using and what type of templates are you using (Masterpages or Views/Mvc)?

    Either way you could follow my suggestion in the second post above and use an XSLT macro, then drop that macro in your template in place of where you're rendering out the tweets now.

    Something like...

    <xsl:if test="$currentPage/showTweets = '1'">
     <a href="{$currentPage/tweet1Link}">
       <xsl:value-of select="$currentPage/tweet1Title" />
     </a>
     <a href="{$currentPage/tweet2Link}">
       <xsl:value-of select="$currentPage/tweet2Title" />
     </a>
    </xsl:if>

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft