Copied to clipboard

Flag this post as spam?

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


  • Laurent Lequenne 16 posts 36 karma points
    Feb 01, 2011 @ 12:36
    Laurent Lequenne
    0

    Get custom node value

    Something that could simple I think, but I don't find anything on google.

    <xsl:value-of select="$currentPage/../widgetRight1"/>

    This gets the property 'widgetRight1' from the parent page. I would like that this property is passed from a parameter of the xsl => $widgetField.

    How can i transform my value-of to get that custom node from the parent ?

    Thanks for any help...

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 01, 2011 @ 12:42
    Kim Andersen
    1

    Hi Laurent

    You want to put the alias of a property inside a a parameter on the macro, and then use that variable to grab the right property?

    If thats the case you can do something like this:

    <xsl:variable name="widgetField" select="macro/paramName" />
    <xsl:value-of select="$currentPage/../*[name()=$widgetField]" >/

    /Kim A

  • Laurent Lequenne 16 posts 36 karma points
    Feb 01, 2011 @ 13:53
    Laurent Lequenne
    0

    That's it,it works like a charm :=-)

    The idea is to get zones defined as fields in my templates. Those zones are links to other items in the content manager that have their own templates.

    In the page template I defined the zones easily. All my document types derives from some document types that defines a page layout (template) and the zones as properties of the document.  It's a first start to get a CMS somewhat more dynamic. The customer will be able to create his own pages, and related to the layout and document type he choose, he will be able to link widgets for each defined zone.

    But in the future, it will be great if we could separate each content item in multiple document types => One related to the content itself, it defines the main flow, one related to the navigation, and some other types, that bound together can form a complete page. For now the difficulty is that the layout is strictly bound to the content and that it's not easy to change the document type of a content item. So that will bring some trouble if the user want to user a lot of different layouts.

    The template of the master layout contains something like this

    <asp:Content ContentPlaceHolderId="content" runat="server">

      <umbraco:Macro PageId="[#imageLeft]" Alias="WidgetRenderer" runat="server"></umbraco:Macro>
      <umbraco:Macro PageId="[#imageCenter]" Alias="WidgetRenderer" runat="server"></umbraco:Macro>
      <umbraco:Macro PageId="[#textRight]"  Alias="WidgetRenderer" runat="server"></umbraco:Macro>
    </asp:Content>

    This call the Macro here below, that  calls the umbraco.library:RenderTemplate to render the linked content. To not copy over and over content, if no zone is defined and the copyWidgetsToChild property of the parent is set, it render the linked content of the parent page.

     

    <?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"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

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

      <xsl:param name="currentPage"/>
      <xsl:variable name="PageId" select="/macro/PageId"/>
      <xsl:variable name="Field" select="/macro/Field"/>
      <xsl:template match="/">
        <xsl:choose>
          <xsl:when test ="$PageId != '' and $PageId > '0'">
            <xsl:variable name="TemplateId" select="umbraco.library:GetXmlNodeById($PageId)/./@template"/>
            <xsl:if test="$TemplateId != ''">
              <xsl:value-of select="umbraco.library:RenderTemplate($PageId,$TemplateId)" disable-output-escaping="yes"/>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <xsl:if test="$currentPage/../copyWidgetsToChild = '1'">
              <xsl:variable name="parentPageWidget" select ="$currentPage/../*[name()=$Field]"/>
              <xsl:variable name="TemplateId" select="umbraco.library:GetXmlNodeById($parentPageWidget)/./@template"/>
              <xsl:if test="$TemplateId != ''">
                <xsl:value-of select="umbraco.library:RenderTemplate($parentPageWidget,$TemplateId)" disable-output-escaping="yes"/>
              </xsl:if>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft