Copied to clipboard

Flag this post as spam?

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


  • Simon Goldsmith 14 posts 33 karma points
    Nov 12, 2013 @ 13:07
    Simon Goldsmith
    0

    Issue hiding content based on recursive property?

    I have a property in my Master document type called "hideSocialMediaPanel" and this has a true/false type.

    In my main template I have the following code that should show or hide the content based on this value, but it is not working! Help!

    @if(Model.Content.HasValue("hideSocialMediaPanel", recursive:true) == false)
                {
                    <ul class="share">
                    <!--li><a href="#!" class="share grad" title="Share this content"><span>share this content</span></a></li-->
                    <li><a href="#!" class="print grad" onClick="window.print();"><span>print this</span></a></li>
                    <li><a href="https://twitter.com/share" class="twitter grad" title="Share this content via Twitter" data-dnt="true" target="_new" data-lang="en" data-via="twitterapi"><span>share this content via twitter</span></a></li>
                    <li class="facebook grad">
                        <a href="#!" class="facebook grad" title="Share this content via Facebook"><span>share this content via facebook</span></a>
                        <div class="fb-like" data-href="https://www.facebook.com/BrentCouncil?ref=ts&amp;fref=ts" data-send="false" data-width="320" data-show-faces="false" data-font="trebuchet ms" data-action="recommend"></div>
                    </li>
                    <li><a href="/pages/mailing-list/" class="email grad" title="Join the mailing list"><span>join the mailing list</span></a></li>
                </ul>
                }
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 12, 2013 @ 13:35
    Dennis Aaen
    0

    Hi Simion.

    I have just make a small example of a way that you could do it.

    I have an true false datatype call test

     

    @if(Model.Content.Test){
       
    <p>Checkboxischecked</p>
    } else {
      <p>Checkbox is not checked</
    p>
    }

    The documentation can be found here:

    http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/True-False

    Hope this small example can pull you in the right direction for a solution

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 12, 2013 @ 15:06
    Dennis Aaen
    0

    And get a propperty recursive in Razor:

    @* Get the "siteName" property recursively (if not present on current page, traverse through page ancestors, Notice this matches alias casing, but prefixes a _ char *@ @Model._siteName

    Full documentation for this can be found here:

    http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Properties#Model_propertyAlias

    /Dennis

  • Simon Goldsmith 14 posts 33 karma points
    Nov 12, 2013 @ 15:37
    Simon Goldsmith
    0

    If I try something similar in my template;

    @if(Umbraco.Field("hideSocialMediaPanel", recursive:true))
                {
                } 
                else
                {
                    <ul class="share">
                    <!--li><a href="#!" class="share grad" title="Share this content"><span>share this content</span></a></li-->
                    <li><a href="#!" class="print grad" onClick="window.print();"><span>print this</span></a></li>
                    <li><a href="https://twitter.com/share" class="twitter grad" title="Share this content via Twitter" data-dnt="true" target="_new" data-lang="en" data-via="twitterapi"><span>share this content via twitter</span></a></li>
                    <li class="facebook grad">
                        <a href="#!" class="facebook grad" title="Share this content via Facebook"><span>share this content via facebook</span></a>
                        <div class="fb-like" data-href="https://www.facebook.com/BrentCouncil?ref=ts&amp;fref=ts" data-send="false" data-width="320" data-show-faces="false" data-font="trebuchet ms" data-action="recommend"></div>
                    </li>
                    <li><a href="/pages/mailing-list/" class="email grad" title="Join the mailing list"><span>join the mailing list</span></a></li>
                </ul>
                }   
    

    Breaks with the error;

    CS0029: Cannot implicitly convert type 'System.Web.IHtmlString' to 'bool'
    

    Even though the document type property is TRUE/FALSE What am I missing, this should be easy...

  • Simon Goldsmith 14 posts 33 karma points
    Nov 12, 2013 @ 15:50
    Simon Goldsmith
    0

    If I try something similar in my template;

    @if(Umbraco.Field("hideSocialMediaPanel", recursive:true))
                {
                } 
                else
                {
                    <ul class="share">
                    <!--li><a href="#!" class="share grad" title="Share this content"><span>share this content</span></a></li-->
                    <li><a href="#!" class="print grad" onClick="window.print();"><span>print this</span></a></li>
                    <li><a href="https://twitter.com/share" class="twitter grad" title="Share this content via Twitter" data-dnt="true" target="_new" data-lang="en" data-via="twitterapi"><span>share this content via twitter</span></a></li>
                    <li class="facebook grad">
                        <a href="#!" class="facebook grad" title="Share this content via Facebook"><span>share this content via facebook</span></a>
                        <div class="fb-like" data-href="https://www.facebook.com/BrentCouncil?ref=ts&amp;fref=ts" data-send="false" data-width="320" data-show-faces="false" data-font="trebuchet ms" data-action="recommend"></div>
                    </li>
                    <li><a href="/pages/mailing-list/" class="email grad" title="Join the mailing list"><span>join the mailing list</span></a></li>
                </ul>
                }   
    

    Breaks with the error;

    CS0029: Cannot implicitly convert type 'System.Web.IHtmlString' to 'bool'
    

    Even though the document type property is TRUE/FALSE What am I missing, this should be easy...

Please Sign in or register to post replies

Write your reply to:

Draft