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: body id?

  1. #1
    emilym is offline Junior Member
    Join Date
    Jan 2011
    Posts
    11

    Question body id?

    Is it possible to set a different body id (e.g. <body id="something">) for different sections of my store, so that each section's <body> tag can be styled differently with CSS?

    If it is at all possible to do this, how would I go about doing it?

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

    Default

    Hi

    Yes, this is possible but it needs some XMLPackage programming. I'll try to give you an example in V9...

    In your template.master, instead of a <body> HTML tag, use this line:

    Code:
    <asp:Literal runat="server" Text="<%$ Tokens: XmlPackage, header.xml.config%>" />
    Now, create an XML Package called 'header.xml.config' in your \App_Templates\Skin_1\XmlPackages directory that looks something like this:

    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Body tag code" debug="false" includeentityhelper="false">
      <PackageTransform>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
          <xsl:output method="html" omit-xml-declaration="yes" />
    
          <xsl:template match="/">
            <xsl:choose>
    			<xsl:when test="/root/Runtime/PageName='c-123-pageexample.aspx'" ><xsl:text disable-output-escaping="yes"><![CDATA[<body id="style1">]]></xsl:text></xsl:when>
    			<xsl:when test="/root/Runtime/PageName='c-456-pageexample.aspx'" ><xsl:text disable-output-escaping="yes"><![CDATA[<body id="style2">]]></xsl:text></xsl:when>
    			<xsl:otherwise><xsl:text disable-output-escaping="yes"><![CDATA[<body>]]></xsl:text></xsl:otherwise>
    		</xsl:choose>
    
          </xsl:template>
        </xsl:stylesheet>
      </PackageTransform>
    </package>
    In the example above, a different <body id=''> is generated depending on the page. You can of course change this code to suit your requirements.

    Adam
    Last edited by webopius; 02-08-2011 at 02:58 AM. Reason: typo

  3. #3
    emilym is offline Junior Member
    Join Date
    Jan 2011
    Posts
    11

    Default

    cool thank you, how would I do this in Version 8?