Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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&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> }
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
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
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&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...
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
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!
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
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
And get a propperty recursive in Razor:
Full documentation for this can be found here:
http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Properties#Model_propertyAlias
/Dennis
If I try something similar in my template;
Breaks with the error;
Even though the document type property is TRUE/FALSE What am I missing, this should be easy...
If I try something similar in my template;
Breaks with the error;
Even though the document type property is TRUE/FALSE What am I missing, this should be easy...
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.