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
Hi,
I'm very new to Umbraco - with about 4 hrs experience, so sorry for what might be a 'silly question'
So in my DocType I have added a True/False field.
In my template I am then trying to show/hide content based on whether that value is True or False.
I have tried a number of, what I hoped might be solutions, but they either don't appear to do anything or cause a runtime error.
If I hardcode in
@if ("True" == "True") { <div>Show me</div> }
That seems to work.
But if I replace the first value with the property? I am trying to check, not so good e.g..
@if ("@Umbraco.Field("showBanner1")") == "True") { <div>Show Me</div> }
or
@if (Model.Content.GetPropertyValue("showBanner1") == "True") { <div>Show me</div> }
I've even tried
@{var show = @Umbraco.Field("showBanner1");} @{var show2 = @Umbraco.Field("showBanner1");} @if ("@show" == "@show2") { <div>Show Me</div> }
So with the last one, even when I am checking the value against itself it doesn't appear to work, so I know I'm doing something wrong.
Any help would be most appreciated.
Thanks.
Hi Russel and welcome to our :)
Could you please try the snippet of code below here.
@if (Model.Content.GetPropertyValue<bool>("showBanner1")) { <div>Show me</div> }
Then the div will be shown when you have ticked the true / false property on the page that you are viewing in the browser.
Hope this helps,
/Dennis
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
Simple IF statement??
Hi,
I'm very new to Umbraco - with about 4 hrs experience, so sorry for what might be a 'silly question'
So in my DocType I have added a True/False field.
In my template I am then trying to show/hide content based on whether that value is True or False.
I have tried a number of, what I hoped might be solutions, but they either don't appear to do anything or cause a runtime error.
If I hardcode in
That seems to work.
But if I replace the first value with the property? I am trying to check, not so good e.g..
or
I've even tried
So with the last one, even when I am checking the value against itself it doesn't appear to work, so I know I'm doing something wrong.
Any help would be most appreciated.
Thanks.
Hi Russel and welcome to our :)
Could you please try the snippet of code below here.
Then the div will be shown when you have ticked the true / false property on the page that you are viewing in the browser.
Hope this helps,
/Dennis
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