Copied to clipboard

Flag this post as spam?

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


  • Tony 13 posts 43 karma points
    Mar 08, 2011 @ 17:40
    Tony
    0

    Paging through tagged projects

    Hi All,
    I've a little problem which I can't seem to figure out, pretty new to xslt so sorry if this is an easy one.

    I'm creating a work portfolio where we can view all projects or view / filter projects by their tags. The structure of which is as follows...


    Home
    - About us
    - People
    - Projects
       - Project 1 (tags: Print, Design)
       - Project 2 (tags: Design)
       - Project 3 (tags: Design, Illustration)
       - Project 4 (tags: Illustration)
       - Project 5 (tags: Film, Digital)

    What I want to do is filter the work by their tags, so if I click on the filter for 'Design' it will show me a list of 3 design projects, click into a project and then let me page through the result eg. previous 2 of 3 next.

    I've got it working without the tags using the code below...

    <xsl:if test="umbraco.library:Request('deliverable') = ''">
        
        <xsl:variable name="prevId" select="number($currentPage/following-sibling::* [@isDoc][1]/@id)"/>
    <xsl:variable name="nextId" select="number($currentPage/preceding-sibling::* [@isDoc][1]/@id)"/>
        
    <span class="sublink">
      
      <xsl:choose>
        <xsl:when test="$prevId &gt; 0"><a href="{umbraco.library:NiceUrl($prevId)}"><img src="/images/but-left.gif" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-left-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:choose>
        <xsl:when test="$nextId &gt; 0"><a href="{umbraco.library:NiceUrl($nextId)}"><img src="/images/but-right.gif" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-right-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:value-of select="count($currentPage/following-sibling::*) + 1" /> / <xsl:value-of select="count($currentPage/ancestor-or-self::* [@level=2]/* [@isDoc and string(umbracoNaviHide) != '1'])" />
     
        </span>
        </xsl:if>

    <xsl:if test="umbraco.library:Request('deliverable') != ''">

    ???? of <xsl:value-of select="tags:getAllTagsInGroup('default')//@nodesTagged"/>

    </xsl:if>

    It's just the paging with the tags that is causing me a headache, any help would be welcome.

     

  • Tony 13 posts 43 karma points
    Mar 08, 2011 @ 17:45
    Tony
    0

    *Note. I've got the site listing the tagged projects ok. It's just paging from one to another when you click in to view more project details that I can't seem to get my head around.

  • Tony 13 posts 43 karma points
    Mar 09, 2011 @ 17:05
    Tony
    0

    Hi, managed to figure this out, code below... (just need to add the project number you're on)

    <xsl:if test="umbraco.library:Request('deliverable') != ''">
        <xsl:variable name="devId" select="umbraco.library:Request('deliverable')"/>
        <xsl:variable name="prevId" select="number($currentPage/following-sibling::* [@isDoc] [contains(deliverableTags, $devId)][1]/@id)"/>
    <xsl:variable name="nextId" select="number($currentPage/preceding-sibling::* [@isDoc] [contains(deliverableTags, $devId)][1]/@id)"/>
        
        <span class="sublink">
          <xsl:choose>
        <xsl:when test="$prevId &gt; 0"><a href="{umbraco.library:NiceUrl($prevId)}?deliverable={$devId}"><img src="/images/but-left.gif" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-left-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:choose>
        <xsl:when test="$nextId &gt; 0"><a href="{umbraco.library:NiceUrl($nextId)}?deliverable={$devId}"><img src="/images/but-right.gif" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-right-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
          <!--???????--> / <xsl:value-of select="count($currentPage/ancestor-or-self::* [@level=2]/* [@isDoc] [contains(deliverableTags, $devId)])"/>
        </span>
      </xsl:if>
  • Christofer 1 post 21 karma points
    Sep 25, 2011 @ 19:19
    Christofer
    0

    Hi, I am trying to understand your code, could you explain what is deliverable and devId?

  • Tony 13 posts 43 karma points
    Sep 26, 2011 @ 12:23
    Tony
    0

    Hi,

    Deliverable is the name for the requestQuery used to identify which button has been clicked.

    DevId is the value of the current button that has been click (which is derived from the deliverable requestQuery).

    You can see it in action at www.infinitedesign.com/ The links under the project section are made up of unique tag entries for each type of work. When you click on a project type the deliverable QueryString is filled and relevan projects are then listed, click on one of the project then the pageing featre can be seen, top right.

    Here is the final code that is being used on the site...

    Anything else just give me a shout.

    <xsl:if test="umbraco.library:Request('deliverable') = ''">
        
        <xsl:variable name="prevId" select="number($currentPage/preceding-sibling::* [@isDoc] [string(mainProject) = '1'] [1]/@id)"/>
    <xsl:variable name="nextId" select="number($currentPage/following-sibling::* [@isDoc] [string(mainProject) = '1'] [1]/@id)"/>
        
    <span class="sublink">
      
      <xsl:choose>
        <xsl:when test="$prevId &gt; 0"><a href="{umbraco.library:NiceUrl($prevId)}"><img src="/images/but-left.gif" alt="Left Button" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-left-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:choose>
        <xsl:when test="$nextId &gt; 0"><a href="{umbraco.library:NiceUrl($nextId)}"><img src="/images/but-right.gif" alt="Right Button" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-right-inv.gif" border="0" />
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:value-of select="count($currentPage/preceding-sibling::* [string(mainProject) = '1']) + 1" /> / <xsl:value-of select="count($currentPage/ancestor-or-self::* [@level=2]/* [@isDoc] [string(mainProject) = '1'] [string(umbracoNaviHide) != '1'])" />
     
        </span>
        </xsl:if>
      
      
      <xsl:if test="umbraco.library:Request('deliverable') != ''">
        <xsl:variable name="devId" select="umbraco.library:Request('deliverable')"/>
        <xsl:variable name="posId" select="umbraco.library:Request('pos')"/>
        <xsl:variable name="prevId" select="number($currentPage/preceding-sibling::* [@isDoc] [contains(deliverableTags, $devId)][1]/@id)"/>
    <xsl:variable name="nextId" select="number($currentPage/following-sibling::* [@isDoc] [contains(deliverableTags, $devId)][1]/@id)"/>
        
        <span class="sublink">
          <xsl:choose>
        <xsl:when test="$prevId &gt; 0"><a href="{umbraco.library:NiceUrl($prevId)}?deliverable={$devId}&amp;pos={$posId - 1}"><img src="/images/but-left.gif" alt="Left Button" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-left-inv.gif" border="0" alt="Left Button"/>
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:choose>
        <xsl:when test="$nextId &gt; 0"><a href="{umbraco.library:NiceUrl($nextId)}?deliverable={$devId}&amp;pos={$posId + 1}"><img src="/images/but-right.gif" alt="Right Button" border="0" /></a>
      </xsl:when>
        <xsl:otherwise>
          <img src="/images/but-right-inv.gif" border="0" alt="Right Button"/>
        </xsl:otherwise>
      </xsl:choose>
          <xsl:value-of select="$posId" /> / <xsl:value-of select="count($currentPage/ancestor-or-self::* [@level=2]/* [@isDoc] [contains(deliverableTags, $devId)])"/>
        </span>
      </xsl:if>
Please Sign in or register to post replies

Write your reply to:

Draft