Copied to clipboard

Flag this post as spam?

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


  • Ivan 139 posts 302 karma points
    Feb 02, 2010 @ 20:48
    Ivan
    0

    I can't make it work correctly, please Help

    Hi:

    I am trying to relate links to an event so i follow these steps:

    1. Add new 'Related Links with Media' Type property to type of document "Event item". The propertyAlias is "eventsRelated".
    2. Edit the event node from "Contents" section and add the related links using the new property added.
    3. Save and Publish changes.
    3. Edit the template associated to the "Event item" adding the following code:

             <umbraco:Macro Alias="RelatedLinkswithMedia" propertyAlias="eventsRelated" runat="server"></umbraco:Macro>

    Problem is i dont get any entries in the frontend or backend (visualize XSLT).

    What am i doing wrong?

    Thanks in advance for your help.

    Ivan

  • Stephan Lonntorp 195 posts 212 karma points
    Feb 02, 2010 @ 20:51
    Stephan Lonntorp
    0

    You need to add a Macro in order to call a Macro, you are trying to access a Property with a Macro control, try <umbraco:Item runat="server" Field="eventsRelated" /> instead. Although, I think you'll need to write a proper macro to get anything good out of the property.

  • Ivan 139 posts 302 karma points
    Feb 02, 2010 @ 21:00
    Ivan
    0

    Hi Stephan:

    I tried adding <umbraco:Item runat="server" Field="eventsRelated" /> and still getting no results.

    Anyway i got the macro "RelatedLinkswithMedia" which xslt file is:

    <?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="xml" omit-xml-declaration="yes" />

    <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/data [@alias = $propertyAlias]/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:when test="./@type = 'media'">
                            <xsl:attribute name="href">
                                <xsl:value-of select="umbraco.library:GetMedia(./@link,0)/data[@alias='umbracoFile']"/>
                            </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>

    </xsl:stylesheet>

     

    Any ideas?

  • Stephan Lonntorp 195 posts 212 karma points
    Feb 02, 2010 @ 21:26
    Stephan Lonntorp
    0

    on the first line, there's a hard-coded propertyAlias, exchange that for your propertyAlias, 'eventsRelated', and try again.

  • Ivan 139 posts 302 karma points
    Feb 02, 2010 @ 22:17
    Ivan
    0

    Thanks Stephan but i am still getting no results.

  • Ivan 139 posts 302 karma points
    Feb 02, 2010 @ 22:20
    Ivan
    0

    I changed my propertyAlias field to "links" and now everything is working properly.

    Thanks a lot for your help Stephan.

    Bye!

Please Sign in or register to post replies

Write your reply to:

Draft