Essentially if your new 'true/value' property has property alias 'hide' then you can read it using the PublishedContent approach by
@Model.Value<bool>("hide")
this reads the value from Umbraco and turns it into a 'bool' which is a boolean value of either true or false, and so you can check if it's false, eg not hidden, and therefore ok to write out the HTML...
Toggle Content on Front End Pages
I am trying to build out an alert section that can be toggled on and off for display on the home page.
It's very possible I have it wrong because I'm still learning. But this is what I've done.
I created a property called "hide" with a true/false toggle. When I try to add the hide to the code, it breaks the page.
See code below.
Any help would be greatly appreciated!
Hi Cedeste
There are different approaches to implementing views, using Published Content or Modelsbuilder, it looks like here you are using 'PublishedContent'...
... so I think something like this
Essentially if your new 'true/value' property has property alias 'hide' then you can read it using the PublishedContent approach by
this reads the value from Umbraco and turns it into a 'bool' which is a boolean value of either true or false, and so you can check if it's false, eg not hidden, and therefore ok to write out the HTML...
regards
Marc
THANK YOU! That worked.
is working on a reply...