1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Setting template property from a content page (sitefinity 4.4)

Setting template property from a content page (sitefinity 4.4)

4 posts, 0 answered
  1. Dmitri
    Dmitri avatar
    8 posts
    Registered:
    17 Jul 2010
    05 Jan 2012
    Link to this post
    the site that I'm working at is designed in a such way that CSS class is set for the <body> tag on all the pages and the css classes used are different for all pages. Each page has common elements such as a header, a footer and a nav bar. I'd like to set up a single page template and include all common elements there but the body tag stands in the way. Is there a way to control a template from a content page? I know I can specify a code behind for content pages but i can't rely on content authors to enter it correctly each time they add a page. My current thinking is to set up multiple page template, one for each css class that is referenced in the body tag and put the common page elements into user controls. This is less than ideal because I will end up with lots of mostly identical templates and my user controls would not be editable easily. I guess I would have to use shared content items and such making the content authors hunt all over the site. I would have been much simpler to update the common header in a single page template.

    Can someone please suggest a way?
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    06 Jan 2012
    Link to this post
    hi dmitri,

    how are the css classes chosen for the body tag? Is the template using a master page? It is possible to set the body css class using the code-behind of the master page so that it is automatically set based on some criteria.

    This way the template can have all the unified elements, but the body class can change based on the code-behind of the master page.

    will that work? If you tell me more about how you choose the body css class I can try to offer different solutions ...

    hope this is helpful!
  3. Dmitri
    Dmitri avatar
    8 posts
    Registered:
    17 Jul 2010
    06 Jan 2012
    Link to this post
    thank you for the reply.

    the site does not have many pages, maybe 20. most of them have different css classes on the body tag. not all 20 have different body css class but most. i want a master page file for my page template so i will a code behind file to work with. i will be glad to use your solution but i'm not sure what type of criteria i can set on a content page to make the master page's code behind set the body css class properly. if content pages had custom properties it would have been easy. i dont think that content pages can have custom properties but is there another technique i can use?
  4. Dmitri
    Dmitri avatar
    8 posts
    Registered:
    17 Jul 2010
    09 Jan 2012
    Link to this post
    OK I got this to work with Meta tags set at the content page level. I read the meta in the master page's code behind and set the body css accordingly. this technically works but the content authors will need to be mindful of this workaround. Still, I with there were page properties.
4 posts, 0 answered