I am trying to add a class of "single" to my body tag if the page I am on, matches a documenttype alias from umbraco.
i have tried this:
<body @{global.CurrentPage.DocumentTypeAlias == "blogItem" ? "class='single'" : '';}>
It should add the class "single" if the currentpage i am on, has a DocumentTypeAlias of "blogItem".
I can't get this to work, and i haven't been able to find a solution so far. What am i doing wrong here ?
it gives me the error: Type of conditional expression cannot be determined because there is no implicit conversion between "string" and "char"
Edit Changing it to this,
<body class="@{global.CurrentPage.DocumentTypeAlias == "blogItem" ? "single" : "";}">
just gives a new error... Only assignment, call, decrement, and new object expressions can be used as a statement.
You've got a couple of things wrong with your syntax. As already pointed out your ''
quotes are wrong, but you also need to surround your expression with ()
rather than {}
:
<body @(global.CurrentPage.DocumentTypeAlias == "blogItem" ? "class='single'" : "")>