Copied to clipboard

Flag this post as spam?

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


  • chris cameron 36 posts 56 karma points
    Jan 23, 2012 @ 08:51
    chris cameron
    0

    tag cloud by group name

    Scenario: Product listing with associated Tags. Each product also hace a product category associated which is stored as a tag. I have managed to get output of all the tags in a tag cloud but are unable to get a list of the categorys (tag groupnames) for some reason. Any ideas please...

     

    <xsl:variable name="currentStore" select="umbraco.library:GetXmlNodeById(Foodstuffs.library:GetCurrentRegionId())"/>
            <xsl:variable name="productsAll" select="$currentStore/ancestor-or-self::*[count(./Promotions/ProductPromotion)&gt;0]/Promotions/ProductPromotion [umbraco.library:DateGreaterThanOrEqual(validEndDate, $currentDate) and umbraco.library:DateGreaterThanOrEqual($currentDate, validStartDate)]"/>

            <xsl:variable name="products" select="$currentStore/ancestor-or-self::*[count(./Promotions/ProductPromotion)&gt;0]/Promotions/ProductPromotion [umbraco.library:DateGreaterThanOrEqual(validEndDate, $currentDate) and umbraco.library:DateGreaterThanOrEqual($currentDate, validStartDate) and contains(Exslt.ExsltStrings:lowercase(./tags), Exslt.ExsltStrings:lowercase($filter))]"/>
            <xsl:variable name="productscat" select="$currentStore/ancestor-or-self::*[count(./Promotions/ProductPromotion)&gt;0]/Promotions/ProductPromotion [umbraco.library:DateGreaterThanOrEqual(validEndDate, $currentDate) and umbraco.library:DateGreaterThanOrEqual($currentDate, validStartDate) and contains(Exslt.ExsltStrings:lowercase(./category), Exslt.ExsltStrings:lowercase($filter))]"/>
    <!-- START TAG CLOUD -->
            <xsl:variable name="numberOfRecords" select="count($products)"/>
           
            <xsl:value-of select="$numberOfRecords"/>
            <br/>
           
            <p>TAGS</p>
            <xsl:if test="number($numberOfRecords) &gt;0">
              <xsl:variable name="commaListofTags">
                <xsl:for-each select="$productsAll/tags">
                  <xsl:value-of select="concat(.,',')"/>
                </xsl:for-each>
              </xsl:variable>
              <xsl:value-of select="$commaListofTags"/>
             
              <p>TAG</p>
              <article class="clear martop20">
                <div class="curved10 brd4px tagCloudGeneric rel">
                  <a class="curved5 sortButton" href="/promotions-competitions/?numberPerPage={$numberPerPage}">Show All</a>
                  <p>
                    <xsl:for-each select="tagsLib:getAllTags()/tags/tag[@group = 'ProductPromotion']">

                      <xsl:if test="contains(Exslt.ExsltStrings:lowercase($commaListofTags),Exslt.ExsltStrings:lowercase(.))">

                        <a>
                          <xsl:attribute name="href">
                            <xsl:value-of select="concat(umbraco.library:NiceUrl($currentPage/@id),'?numberPerPage=',$numberPerPage,'&amp;filter=',.)"/>
                          </xsl:attribute>
                          <xsl:attribute name="class">
                            <xsl:choose>
                              <xsl:when test="@nodesTagged &gt; 5">
                                <xsl:value-of select="string('tagweight5')"  />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:value-of select="concat('tagweight',@nodesTagged)"/>
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:attribute>
                          <xsl:value-of select="."/>
                        </a>
                        <xsl:text> </xsl:text>

                      </xsl:if>
                    </xsl:for-each>
                  </p>

                  <div class="clear">
                    <xsl:value-of select="''"/>
                  </div>
                </div>
              </article>
              <!-- END TAG list -->

     

    <!-- START CATEGORY LIST -->
              <P>CATEGORY</P>
              <xsl:variable name="numberOfRecordscat" select="count($productscat)"/>
              <xsl:value-of select="$numberOfRecordscat"/>
              <br/>
              <p>CATEGORY</p>
              <xsl:variable name="commaListofcat">
                <xsl:for-each select="$productsAll/category">
                  <xsl:value-of select="concat(.,',')"/>
                </xsl:for-each>
              </xsl:variable>
              <xsl:value-of select="$commaListofcat"/>
             
              <p>CATEGORY LINKS</p>
              <article class="clear martop20">
                <div class="curved10 brd4px tagCloudGeneric rel">
                  <a class="curved5 sortButton" href="/promotions-competitions/?numberPerPage={$numberPerPage}">Show All</a>
                  <p>
                    <xsl:for-each select="tagsLib:getAllTagsInGroup('commaListofcat')/tags/tag[@group = 'ProductPromotion']">

                      <xsl:if test="contains(Exslt.ExsltStrings:lowercase($commaListofcat),Exslt.ExsltStrings:lowercase(.))">

                        <a>
                          <xsl:attribute name="href">
                            <xsl:value-of select="concat(umbraco.library:NiceUrl($currentPage/@id),'?numberPerPage=',$numberPerPage,'&amp;filter=',.)"/>
                          </xsl:attribute>
                          <xsl:attribute name="class">
                            <xsl:choose>
                              <xsl:when test="@nodesTagged &gt; 5">
                                <xsl:value-of select="string('tagweight5')"  />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:value-of select="concat('tagweight',@nodesTagged)"/>
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:attribute>
                          <xsl:value-of select="."/>
                        </a>
                        <xsl:text> </xsl:text>

                      </xsl:if>
                    </xsl:for-each>
                  </p>

                  <div class="clear">
                    <xsl:value-of select="''"/>
                  </div>
                </div>
              </article>
              <!-- END CATEGORY tag list -->

  • chris cameron 36 posts 56 karma points
    Jan 23, 2012 @ 09:39
    chris cameron
    0

    Further to the above; I have found that I made a mistake and changed the tag folder structure. This adjusted and I can get a second list of current tags but are still unable to list the categories. Whenever I us getAllTagsInGroup I get an error thrown however getAllTags works and returns the tag list.

    <p>CATEGORY</p>
              <xsl:variable name="commaListofcat">
                <xsl:for-each select="$productsAll/tags">
                  <xsl:value-of select="concat(.,',')"/>
                </xsl:for-each>
              </xsl:variable>
              <xsl:value-of select="$commaListofcat"/>

    <p>
                    <xsl:for-each select="tagsLib:getAllTags()/tags/tag[@group = 'ProductPromotion']">

                      <xsl:if test="contains(Exslt.ExsltStrings:lowercase($commaListofcat),Exslt.ExsltStrings:lowercase(.))">

  • chris cameron 36 posts 56 karma points
    Jan 23, 2012 @ 09:52
    chris cameron
    0

    OK by removing [@group = 'ProductPromotion'] I was able to get a list of categories out, dunno if it right completely but worked.

Please Sign in or register to post replies

Write your reply to:

Draft