Copied to clipboard

Flag this post as spam?

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


  • Dane Garcia 6 posts 56 karma points
    Feb 12, 2013 @ 19:45
    Dane Garcia
    0

    Using Page Parameter as Macro Parameter

    I'm trying to display a embedded PDF and am having some trouble passing the page parameter which is a media selector named "document". I have a working macro that just needs me to pass a value containing the NodeID of "document". I am currently trying this code:

    <umbraco:Macro Alias="OpenPDF" runat="server">
    <umbraco:Parameter Name="pdfFile">
    <umbraco:Item field="document" runat="server" />
    </umbraco:Parameter>
    </umbraco:Macro>

    I'm getting a parse error stating <umbraco:Item field="document" runat="server" /> "The 'Text' property of 'umbraco:Macro' does not allow child objects.

  • Dane Garcia 6 posts 56 karma points
    Feb 12, 2013 @ 21:31
    Dane Garcia
    100

    Found a resolution, it is to use the xslt file to do all the work. here is the code that made it work:

    <embed width="100%" height="500">
    <xsl:attribute name="src">
    <xsl:if test="$currentPage/document &gt; 0">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/document, 0)/umbracoFile" />
    </xsl:if>
    </xsl:attribute>
    </embed>

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Feb 12, 2013 @ 22:36
    Chriztian Steinmeier
    0

    Hi Dane,

    Just chipping in with an alternate way to do it using the "Advanced Macro Parameter Syntax" :

    <umbraco:Macro Alias="OpenPDF" documentnode="[#document]" runat="server" />

    Of course you'll need to grab the property in XSLT (which was probably what you already did in your original):

    <xsl:variable name="documentID" select="/macro/documentnode" />
    
    <xsl:if test="normalize-space($documentID)">
        <embed width="100%" height="500" src="{umbraco.library:GetMedia($documentID, 0)/umbracoFile}" />
    </xsl:if>
    

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft