@Dennis the nodeTypeAlias did the trick. For some reason I get an error when trying to do an if/else on the body element. This would be easier and more persistent in the long run, so that all other pages besides the frontpage, would get a class called page etc.
But for now I'm good :) thanks for the help! – And to you too @Benjamin :)
@Flip Dennis' code tells you the document type of the page, my code snippet tells you the actual template (masterpage/Razor) being used - they are two different things (a document type can have multiple templates used to render it to HTML). But HTH regardless :-)
Determining template type and using it for and if else statement.
Hi all :)
I',m fairly new to Umbraco, but I'm stuck at this one. Can I somehow get the template type, and use it in a if/else statement?
example: if 'home' template, then add class 'home' for the body element, else 'do nothing'?
I've been searching around the web for a couple of hours, without any luck.
Project info: Umbraco v. 7.1.6 - MVC
Hi Flip, and welcome our!
With this snippet of code, you are checking what document type you are using for the page. In the example I have a document type called TextPage
Or you could use the one of the standard fields in your body tag like this: http://our.umbraco.org/documentation/Reference/Mvc/views#PropertiesavailableinViews and http://our.umbraco.org/documentation/Reference/Mvc/views#RenderingafieldwithUmbracoHelper
Hope this helps, if not don't hesitate to write again.
/Dennis
Hey,
Here's a quick sample I knocked up. Hope it helps.
@Dennis the nodeTypeAlias did the trick. For some reason I get an error when trying to do an if/else on the body element. This would be easier and more persistent in the long run, so that all other pages besides the frontpage, would get a class called page etc.
But for now I'm good :) thanks for the help! – And to you too @Benjamin :)
@Flip Dennis' code tells you the document type of the page, my code snippet tells you the actual template (masterpage/Razor) being used - they are two different things (a document type can have multiple templates used to render it to HTML). But HTH regardless :-)
@Benjamin Ah, okay. I'm getting it now :) I'm so new to this Umbraco thing, but the community kicks ass :)
is working on a reply...