Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephane Landreville 1 post 0 karma points
    Jun 23, 2009 @ 18:04
    Stephane Landreville
    0

    nested div tags

    Hello.

    I'm currently running the latest release of Umbraco (4).

    I used a lot of nested div tags in my code.
    We are looking to use Umbraco to simplify our work.

    But --- for some odd reason through my testing phase, when I try to use a nested div tag, it removes all internal tags and leaves me with only the external div tag.

    Is there a way around this?

    Here is an example of some code I was trying just to see:

      <div class="nifty-wrapper">
        <div class="nifty-title-box" style="width:460px; margin-bottom:10px; margin-top:10px;">
          <div class="nifty-title-left">
            <div class="nifty-title-right">
              <p class="nifty-title-content">2009 CPMA ANNUAL CONVENTION AND TRADE SHOW HIGHLIGHTS</p>
                </div>
            </div>
        </div>
    </div>

    Thanks in advance for your assistance.

    Stephane

  • dillorscroft 198 posts 192 karma points
    Jun 23, 2009 @ 20:03
    dillorscroft
    0

    Stephane,

    Can you post the XSLT/macro that generates these divs?

    Umbraco by default will not change your divs within a template at all.  It's one of it's strengths.  If it's generated in an XSLT then there are some things to be aware off.  An empty div for instance will render as <div /> which most browsers will not tolerate.

    DC

  • Tom Madden 253 posts 455 karma points MVP 4x c-trib
    Jun 23, 2009 @ 20:06
    Tom Madden
    0

    Stephane,

    You haven't said where you are entering your code. Is it in a template, or in an XSLT macro? 

    If it's an XSLT macro, then I suspect this is a 'feature' of the xslt processing that also strips out the closing tag of an empty div tag and add the foward slash into the opening part of the tag:

        <div class="clear"></div>

    becomes

        <div class="clear" />

    and this results in an error if you run your html through a validator and prevents styles being applied in some browsers

    I use code like this to prevent it:

    To prevent Umbraco stripping empty tag elements use CDATA like:

    <xsl:text disable-output-escaping="yes"><![CDATA[

        <div class="clear"></div>

    ]]></xsl:text>

     

    If this technique doesn't solve it, please say so, and someone else is sure to chip in.

    Tom 

  • Gerben 41 posts 136 karma points
    Jul 03, 2009 @ 00:14
    Gerben
    1

    If you cannot use a CDATA section (for example of you still need xslt logic inside the div)  you can also insert and xsl:comment inside the div.

    <div class="clear"><xsl:comment/></div>

    This will create an html tag like this

    <div class="clear"><!-- --></div>

    Quite ugly actually, but it works.

  • Jesper Hauge 298 posts 487 karma points c-trib
    Jul 10, 2009 @ 00:31
    Jesper Hauge
    0

    Or you could try changing the output method:

    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    to
    
    <xsl:output method="html" />

    This will make the xsl-parser leave your div tags empty, I think.

    Regards
    .Hauge

Please Sign in or register to post replies

Write your reply to:

Draft