Copied to clipboard

Flag this post as spam?

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


  • Grant 21 posts 61 karma points
    Nov 01, 2013 @ 19:29
    Grant
    0

    Product Grid / List nodes from "alternate" page

    I am building a eCommerce style site, and my question is about displaying nodes from a source other than $currentPage. How can I target one of my categories nodes? To build a product I have a raiting property int collection for a number 1 - 5. (would this be better handled by a dropdown, or radio set?) So essentially the homepage will pull say the top 5 (5 star) items.

    So far I have the grid generating thumbnails and links but I have to place it on a node with product children due to my unsuccessful searches for node targeting.

    Hope I made sense, and thanks in advance.

    So far:

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <div class="twelve columns">
    <div class="row">
    <!-- The fun starts here -->
    <ul class="portfolio-items">
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
    <li class="img_item">
    <div class="caption15">
    <h3><xsl:value-of select="productName"/></h3>
    <p><a href="{umbraco.library:NiceUrl(@id)}" class="gridBuy">Product Info</a></p>
    </div>
    </li>
    </xsl:for-each>
    </ul>
    </div>
    </div>
    </xsl:template>
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 02, 2013 @ 23:21
    Chriztian Steinmeier
    100

    Hi Grant,

    You have all of the published content available - you just need to know how to get it. A good trick is to grab some good reference points, instead of getting everything off of $currentPage, which quickly becomes unreadable. So for example, I always create a $siteRoot variable just after the $currentPage parameter, like this:

    <xsl:param name="currentPage" />
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    

    This makes it very easy to grab stuff from other places, e.g. your categories - if they're placed outside your site, you'd do this:

    <xsl:variable name="categories" select="$siteRoot/../Categories" />
    

    Otherwise, if they're placed below the home node:

    <xsl:variable name="categories" select="$siteRoot/Categories" />
    

    Then to get the name of the Category that your category property on $currentPage is pointing at, do this:

    <xsl:value-of select="$categories/Category[@id = $currentPage/category]/@nodeName" />
    

    /Chriztian

  • Grant 21 posts 61 karma points
    Nov 03, 2013 @ 01:36
    Grant
    0

    Wow, very informative thank you got my solution and a best practice...Thanks, again.

    -G

  • 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