3

I'm trying to use the Checkbox/TrueFalse to toggle on/off certain parts of content, however it seems that no matter what setting I put the checkbox on, the Value (even parsed as Bool) always returns false.

I'm wondering if theres a property I'm missing, or if I'm somehow just completely doing it wrong.

@if(item.Value<bool>("includeButton")) {
    var linkUrl = item.Value<IPublishedContent>("buttonLink").Url;
    <a href="@linkUrl" class="Button Button--primary">@item.Value("buttonLabel")</a>
}

I've tried a few different methods, but to no success.

Any help appreciated.

UPDATE

This is a known issue inside Umbraco 8.0

https://github.com/umbraco/Umbraco-CMS/issues/4812

James Lalor
  • 1,236
  • 9
  • 22
  • I have only done this directly against Model properties so far in 8, however in my case I am able to just go directly to the property. Try @if(item.IncludeButton")) {} should be no need to cast it. – hardba11 Apr 03 '19 at 18:56
  • @hardba11 will I need to enable strongly typed models for this? – James Lalor Apr 04 '19 at 03:47
  • are you in a loop there? If so,why? is it nested content or something of the sort? – Jabberwocky Apr 04 '19 at 12:38
  • @Jabberwocky yes, it's loop of items which each have option for a button, but just always returns false. – James Lalor Apr 04 '19 at 20:38

0 Answers0