Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 3 of 3

Thread: Dynamic body tag

  1. #1
    thepcgeneral is offline Junior Member
    Join Date
    Jan 2008
    Posts
    2

    Default Dynamic body tag

    I have a site that I am converting to the storefront, and this site loads dynamic styles per page. Depending on the page you are on, the body tag gets updated with different id's and classes.

    Is there a way to implement this same functionality in the storefront based on the page name?

  2. #2
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Just use an xmlpackage to write your body tag in the template.



    TTFN

    BFG

  3. #3
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    ...and here's an example of one I've used before:

    In your template.master include this:

    Code:
    <asp:Literal runat="server" Text="<%$ Tokens: XmlPackage, body.xml.config %>" />
    Then, in a body.xml.config XMLPackage, include a line such as this:

    Code:
    <xsl:choose>
       <xsl:when test="$Category=1" >
         <xsl:text disable-output-escaping="yes"><![CDATA[<body class="category1">]]></xsl:text>
       </xsl:when>
       <xsl:otherwise>
         <xsl:text disable-output-escaping="yes"><![CDATA[<body>]]>  </xsl:text>
       </xsl:otherwise>
    </xsl:choose>
    In this simple example, I set the class of the body based on an XSL Param called $Category. In real versions, it can get a lot more complex than this and you can create custom CSS styles for specific pages based on product, category, page name etc.