Copied to clipboard

Flag this post as spam?

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


  • Brian Juul Andersen 43 posts 97 karma points c-trib
    Jan 17, 2013 @ 10:31
    Brian Juul Andersen
    0

    editor macro "bleeds" id / content into other macros

     

    Hi guys.

     

    I have the following setup:

     

    Umbraco 4.0.2.1 (I know .. really old - nothing I can do about it :/ )

     

    On a page I have three columns/divs (see fine ASCII graphics below :) ).

     

    The two side bars are meant to show content (little boxes) that are chosen through a Multiple Content Picker.

    No problem as long as the boxes are of a document type with just a picture and a headline.

     

    The problem starts when boxes of a document type that contains a field of the type Rich Text Editor are chosen AND the RTE field

    contains media (picture) or a editor macro. Sadly this is what I need.

     

    Example:

     

    [sideBarLeft] [content] [sideBarRight]

    ------------------------------------

    [lBox1   id1] [content] [lBox11  id42]

    [lBox2   id4] [from    ] [etc.        ]

    [boxRTE id42] [node   ] [etc.        ]

    [lbox3  id42] [id42    ] [etc.        ]

     

     

    sideBarLeft and sideBarRight each has their own XSLT macro that iterates through the chosen boxes from the Multiple Content Picker.

     

    From boxRTE and forward the id seems to "bleed through" to the other XSLT macro and content - but how ?

     

    What puzzles me even more is that if I debug with an alternative template that has:

    <textarea>
    <xsl:copy-of select="$currentPage" />
    </textarea>

    in it... I get the right node id, values from fields etc.

     

     

    Any feed back is welcome. I´ve been pulling my hair out on this one for two days already :)

    XSLT code are here below:
    sideBarLeft - XSLT
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:KvExtensions="urn:KvExtensions" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets KvExtensions ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="settingNode" select="31331" />
    <xsl:variable name="sidebar" select="$currentPage/data[@alias='IH_OKD_sidebarLeft']" />
    <xsl:template match="/">
    <xsl:variable name="boxPool">
    <xsl:choose>
    <!-- are there any boxes chosen for this page ? -->
    <xsl:when test="$sidebar != ''">
    <xsl:value-of select="$sidebar" />
    </xsl:when>
    <!-- .. otherwise use default settings -->
    <xsl:otherwise>
    <xsl:value-of select="umbraco.library:GetXmlNodeById($settingNode)/data[@alias='IH_OKD_sidebarLeftStd']"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="sideBoxes" select="umbraco.library:Split($boxPool, ',')" />
    <!-- iterate through the boxes .. -->
    <xsl:for-each select="$sideBoxes/value">
    <xsl:variable name="currItem" select="umbraco.library:GetXmlNodeById(.)" />
    <!-- and render each of them by calling the following macro with parameters -->
    <xsl:variable name="macro">
    <![CDATA[<?UMBRACO_MACRO macroAlias="[IH][OKD]sideBox" imageId="]]><xsl:value-of select="$currItem/data[@alias='IH_OKD_sidebox_image']" /><![CDATA[" boxLink="]]><xsl:value-of select="$currItem/data[@alias='IH_OKD_sidebox_link']" /><![CDATA[" nodeId="]]><xsl:value-of select="$currItem/@id" /><![CDATA["></?UMBRACO_MACRO>]]>
    </xsl:variable>
    <xsl:value-of select="umbraco.library:RenderMacroContent($macro, .)" disable-output-escaping="yes" />
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

     

    sideBox - XSLT

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:KvExtensions="urn:KvExtensions" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets KvExtensions ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="imageId" select="/macro/imageId" />
    <xsl:variable name="boxLink" select="/macro/boxLink" />
    <xsl:variable name="nodeId" select="/macro/nodeId" />
    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById($nodeId)" />
    <xsl:variable name="nodeType" select="$node/@nodeTypeAlias" />
    <xsl:variable name="nodeTemplate" select="$node/@template" />
    <xsl:template match="/">
    <xsl:choose>
    <xsl:when test="$nodeTemplate = 31917">
    <!-- boxes of type boxRTE -->
    <xsl:value-of select="umbraco.library:RenderTemplate($nodeId, $nodeTemplate)" disable-output-escaping="yes" />
    </xsl:when>
    <xsl:when test="$nodeTemplate = 31641">
    <!-- boxes of type lBox -->
    <xsl:choose>
    <xsl:when test="$imageId != ''">
    <xsl:variable name="media" select="umbraco.library:GetMedia($imageId, 0)/data" />
    <xsl:variable name="url" select="$media[@alias = 'umbracoFile']" />
    <xsl:variable name="width" select="$media[@alias = 'umbracoWidth']" />
    <xsl:variable name="height" select="$media[@alias = 'umbracoHeight']" />
    <xsl:choose>
    <xsl:when test="$boxLink !=''">
    <a>
    <xsl:attribute name="href"><xsl:value-of select="umbraco.library:NiceUrl($boxLink)" /></xsl:attribute>
    <xsl:attribute name="alt"><xsl:text></xsl:text></xsl:attribute>
    <xsl:attribute name="title"><xsl:text></xsl:text></xsl:attribute>
    <xsl:attribute name="class"><xsl:text>portlet-right</xsl:text></xsl:attribute>
    <img>
    <xsl:attribute name="src"><xsl:value-of select="$url" /></xsl:attribute>
    <xsl:attribute name="width"><xsl:value-of select="$width" /></xsl:attribute>
    <xsl:attribute name="height"><xsl:value-of select="$height" /></xsl:attribute>
    </img>
    </a>
    </xsl:when>
    <xsl:otherwise>
    <img>
    <xsl:attribute name="src"><xsl:value-of select="$url" /></xsl:attribute>
    <xsl:attribute name="width"><xsl:value-of select="$width" /></xsl:attribute>
    <xsl:attribute name="height"><xsl:value-of select="$height" /></xsl:attribute>
    <xsl:attribute name="class"><xsl:text>portlet-right</xsl:text></xsl:attribute>
    </img>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
    <div>
    No picture !!!
    </div>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>

     

  • Charles Afford 1163 posts 1709 karma points
    Jan 22, 2013 @ 23:05
    Charles Afford
    0

    Hi, not sure i understand the problem here?  Could you explain what you mean by bleeding?  Thanks.  Charles :)

  • Charles Afford 1163 posts 1709 karma points
    Jan 22, 2013 @ 23:11
    Charles Afford
    0

    Have you checked to see if something like  

    <xsl:attributename="alt"><xsl:text></xsl:text></xsl:attribute>

    is giving you a self closing tag /> instead of </xsl:attribute> This would caused that error and its happened to me before :)

Please Sign in or register to post replies

Write your reply to:

Draft