Copied to clipboard

Flag this post as spam?

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


  • J 1 post 21 karma points
    Jun 16, 2011 @ 12:42
    J
    0

    Render different document type data based on url

    Hi All

    I have looked around with no luck to finding the solution to this.
    The goal is to have one page that can serve (show/hide various data items) based on the URL.

    What I have is a document type with 3 custom properties.
    Lets call them Prop1/Prop2 and Prop3. All properties are of type (Rich Editor)

    What I would like to do is have some logic is xslt that will pick up the URL and based on the path, render the appropiate Prop data only.

    Example,

    domain.com/Prop1/Welcome.aspx will show a page with the Prop1 content data only.

    domain.com/Prop2/Welcome.aspx will show a page with the Prop2 content data only and so on.

    I have it setup so the welcome page is a linked page so this is all happening on the page. I just need thre ability to make it dynamic based on the URL.

    Any suggestions?

    Thanks

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2011 @ 19:30
    Lee Kelleher
    0

    Hi J,

    You've probably figured out a solution for this, but thought I'd offer this little code snippet...

    <!-- gets the URL -->
    <xsl:variable name="url" select="umbraco.library:RequestServerVariables('URL')" />
    
    <!-- loops through each of the document's properties (e.g. ones that DONT have @isDoc attribute) -->
    <xsl:for-each select="$currentPage/*[not(@isDoc)]">
        <!-- tests if the URL contains the property's name/alias -->
        <xsl:if test="contains($url, name())">
            <!-- if so, then output the inner text/content -->
            <xsl:value-of select="text()" />
        </xsl:if>
    </xsl:for-each>

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft