Copied to clipboard

Flag this post as spam?

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


  • Yael Manshary 17 posts 57 karma points
    Dec 27, 2012 @ 13:43
    Yael Manshary
    0

    Content Picker and umbracoUrlAlias

    Hi guys,

    I am using a content picker on a macro, and the pages I am linking to have certain umbracoUrlAlias.

    When entering the page through the link, the page "looses" its umbracoUrlAlias.

    In other words, the content picker ignores the umbracoUrlAlias.

    This is my code:

    <xsl:param name="currentPage"/>

    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->

    <ul id="mycarousel" class="jcarousel-skin-tango">

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1473)//* [@isDoc][not(umbracoNaviHide = 1)][not(self::RelatedFile)]">

    <li>

    <div class="folio-thumb">

    <xsl:if test="string(link) != ''">

    <a class="" href="{umbraco.library:NiceUrl(link)}">

    <img class="" src="{./listItemImg}" alt="{listItemImgAlt}" title="{listItemImgTitle}" />

    </a>

    </xsl:if>

    </div>       

    <h5>

    <a class="" href="{umbraco.library:NiceUrl(link)}">

    <xsl:value-of select="listItemTitle" disable-output-escaping="yes"/>

    </a>

    </h5>

    <a class="Quick-Pick-Text" href="{umbraco.library:NiceUrl(link)}">

    <xsl:value-of select="listItemText" disable-output-escaping="yes"/>

    </a>

    </li>

    </xsl:for-each>

    </ul>

    </xsl:template>

    How do I make the content picker to display the url as it is set in umbracoUrlAlias?

    Thank you in advance,

    Yael

  • Jeremy Pyne 106 posts 246 karma points MVP c-trib
    Dec 27, 2012 @ 21:12
    Jeremy Pyne
    0

    This makes sence.  The Alias is jsut an extra name that the page will respond to but the main url is still the original url.  If you want all the links to use a alternate url from the name of the page then you need to use umbracoUrlName instead witch changes the acctual page url instead of jsut adding an alternate one.

  • Yael Manshary 17 posts 57 karma points
    Dec 30, 2012 @ 10:16
    Yael Manshary
    0

    Hi Jeremy,

    I did not know this, thanks for letting me know.

    The umbracoUrlName isn't what I need but thank you anyway!

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Dec 30, 2012 @ 12:18
    Chriztian Steinmeier
    100

    Hi Yael,

    You should be able to do what you want, though it'll take a little more work... here's how to do it:

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1473)//*[@isDoc][not(umbracoNaviHide = 1)][not(self::RelatedFile)]">
        <li>
            <div class="folio-thumb">
                <a class="">
                    <xsl:apply-templates select="link" />
                    <img class="" src="{listItemImg}" alt="{listItemImgAlt}" title="{listItemImgTitle}" />
                </a>
            </div>
            <h5>
                <a class="">
                    <xsl:apply-templates select="link" />
                    <xsl:value-of select="listItemTitle" disable-output-escaping="yes" />
                </a>
            </h5>
            <a class="Quick-Pick-Text">
                <xsl:apply-templates select="link" />
                <xsl:value-of select="listItemText" disable-output-escaping="yes" />
            </a>
        </li>
    </xsl:for-each>
    
    <xsl:template match="link">
        <!-- Make sure a link was picked -->
        <xsl:if test="normalize-space(.)">
            <!-- Grab the actual node -->
            <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
            <xsl:attribute name="href">
                <xsl:choose>
                    <!-- If it has an alias assigned, use that -->
                    <xsl:when test="normalize-space($node/umbracoUrlAlias)">
                        <xsl:value-of select="concat('/', $node/umbracoUrlAlias)" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="umbraco.library:NiceUrl(.)" />
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
        </xsl:if>
    </xsl:template>

    Please note that this does not take multiple URL aliases into account (you'd need to grab the first if you're using multiple aliases).

    You'll also need to add '.aspx' to the concat() if you're not using directory URLs (which you should :-)

    /Chriztian

     

  • Yael Manshary 17 posts 57 karma points
    Dec 30, 2012 @ 13:15
    Yael Manshary
    0

    Yes, it worked!

    Chriztian, You're awsome :)

    Thank you so much!

Please Sign in or register to post replies

Write your reply to:

Draft