Copied to clipboard

Flag this post as spam?

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


  • Seena 14 posts 34 karma points
    Jan 18, 2013 @ 17:52
    Seena
    0

    Dispalying all related links

    How do I go about displaying related links without having to create a separate macro for every document type property? 

    As of right now, I have to hardcode the property alias into separate xslt files. Is there a way to enter different aliases, but just use one macro?

     <xsl:param name="currentPage"/>
    
      <!-- Input the related links property alias here -->
      <xsl:variable name="propertyAlias" select="string('links')"/>
    
      <xsl:template match="/">
    
        <!-- The fun starts here -->
        <ul>
          <xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link">
            <li>
              <xsl:element name="a">
                <xsl:if test="./@newwindow = '1'">
                  <xsl:attribute name="target">_blank</xsl:attribute>
                </xsl:if>
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="./@link"/>
                    </xsl:attribute>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="./@title"/>
              </xsl:element>
            </li>
          </xsl:for-each>
        </ul>
    
        <!-- Live Editing support for related links. -->
        <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
    
      </xsl:template>
  • Charles Afford 1163 posts 1709 karma points
    Jan 18, 2013 @ 21:34
    Charles Afford
    0

    Hey, could you explain this in a bit more detail.  I am confused about what you are trying to do.  When you say macro, do you mean xslt?  Could you explain what you have setup in the content tree as well :).  Thanks 

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jan 18, 2013 @ 22:57
    Chriztian Steinmeier
    0

    Hi Seena,

    If you create a Macro parameter with the alias linkProperty of type propertyTypePicker, you can use that to select the property holding the Related Links, when you insert the macro - just change the variable to this:

    <xsl:variable name="propertyAlias" select="/macro/linkProperty" />

    /Chriztian

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

    Chriztian,  being looking macro parameters but any chance you could explain sort of what they are and how i could apply them in my XSLT?  Thanks, would be really greatful.  Charles :)

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jan 21, 2013 @ 21:11
    Chriztian Steinmeier
    0

    Hi Charles,

    Hadn't seen your question, but here's how they work:

    You create a macro parameter on the Parameters tab of the Macro. You assign it a Name, an Alias and a type (text, media picker etc.)

    When you add the macro to a template (using the GUI) Umbraco will prompt you for values for all the parameters you've defined.

    In the XSLT you can get the values by selecting them as children of the /macro element, using the Alias you've set for the parameter(s) e.g.:

    <xsl:variable name="varname" select="/macro/parameterAlias" />
    ...
    <xsl:value-of select="$varname" />

    Hope that gets you going,

    /Chriztian

    PS: This is because Umbraco executes all XSLT macros by feeding them an XML document that looks like this:

    <macro>
       <parameterAlias>Value for parameter</parameterAlias>
    </macro>

     

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

    Thanks Chriztian :) when and where would i use them?  As opposed to letting a user enter the value in the content tree?  Thanks  Charles.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies