Copied to clipboard

Flag this post as spam?

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


  • Thomas T 66 posts 227 karma points
    Mar 03, 2015 @ 16:26
    Thomas T
    0

    How to display items on choosing specific category ?

    Hi,

               I have a page in my site in which I need to list out product items. Each item has image, link and description. 

    On left side of the page, I listed out the product categories. Now I need to list out corresponding product items on the right side when I choose one category.  How can I achieve this. I attached an image for reference only.


  • Chriztian Steinmeier 2732 posts 8346 karma points MVP 5x admin c-trib
    Mar 03, 2015 @ 18:50
    Chriztian Steinmeier
    1

    Hi Thomas,

    We need to know a little bit more about how your site is set up before we can really help you.

    • Are the product items separate Umbraco nodes?
    • How are they categorized? Do they have a picker of some sort that connects them?

    /Chriztian

  • Jan Skovgaard 11264 posts 23591 karma points MVP 8x admin c-trib
    Mar 03, 2015 @ 21:18
    Jan Skovgaard
    0

    Hi Thomas

    Please don't double post as it can become very confusing for yourself but also for those trying to help you out keeping track of suggestions etc. - If it's been a while since the last answer on a post then try bumping it up or tweeting using the #umbraco hash-tag if someone has time to provide some hints - The original post is in here https://our.umbraco.org/forum/developers/razor/61821-How-to-list-out-contents-based-on-specific-categories- :-)

    Best Regards Jan

  • Thomas T 66 posts 227 karma points
    Mar 04, 2015 @ 05:59
    Thomas T
    0

    Hi Chriztian,

                           I explained here what i did so far in my page for listing product items.

                           Under 'Developer' section, I created a data type called 'category' with 'dropdown list' as property editor.

                           Under 'Settings' section, I created a document type called 'Marketplace' without properties.Then I create 'MarketPlaceItem' doc. type under ' MarketPlace'. Now 

                           'MarketPlace' acts as its master. MarketPlaceItem has name, image, category type as its properties. I assigned 'Category' data type to 'category type' property.

                            Under 'Content' section, I create a node called 'MarketPlace'.Under which, I created  item1,item2,item3 as child nodes with different categories.

                            I listed out categories in page. But I stuck up here to list out corresponding nodes when I clicking particular category.

  • Chriztian Steinmeier 2732 posts 8346 karma points MVP 5x admin c-trib
    Mar 04, 2015 @ 22:56
    Chriztian Steinmeier
    100

    Hi Thomas,

    So what you should do, is to tack the category onto the URL as a QueryString parameter (e.g. "?category=tools"), and then find them like this:

    <!-- Grab the Home node -->
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <!-- Find the MarketPlace node -->
    <xsl:variable name="marketPlace" select="$siteRoot/MarketPlace" />
    
    <!-- Grab the picked category from URL -->
    <xsl:variable name="category" select="umbraco.library:RequestQueryString('category')" />
    
    <!-- Find nodes with this category -->
    <xsl:variable name="selectedNodes" select="$marketPlace/MarketPlaceItem[category = $category]" />
    
    <xsl:template match="/">
        <!-- Process the picked nodes -->
        <xsl:apply-templates select="$selectedNodes" />
    </xsl:template>
    
    <!-- Template for rendering a MarketPlaceItem -->
    <xsl:template match="MarketPlaceItem">
        <div class="item">
            <h1><xsl:value-of select="@nodeName" /></h1>
            <!-- etc. -->
        </div>
    </xsl:template>
    

    /Chriztian

  • Thomas T 66 posts 227 karma points
    Mar 05, 2015 @ 05:42
    Thomas T
    0

    Hi Chriztian,

                                Thanks for the solution.

Please Sign in or register to post replies

Write your reply to:

Draft