Copied to clipboard

Flag this post as spam?

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


  • Rachel Skuse 88 posts 118 karma points
    Oct 31, 2011 @ 16:58
    Rachel Skuse
    0

    Open an accordian item in a new page specific to value in URL

    The following checks if there is a customer testimonial assigned to a product and, if so, creates a link from the product page to the testimonial (with a unique id 'testimLink')

        <xsl:variable name="testimLink" select="$currentPage/data [@alias = 'testimLink']" />

        <xsl:if test="$currentPage/@nodeTypeAlias = 'testimLink'">
            <a href="/testimonials.aspx?t=t{$testimLink}">Customer Testimonial</a>
        </xsl:if>

    The testimonials are all on a separate page in an accordian menu (click on an item and it expands) so what I need to be able to do is expand the testimonial with the 'testimLink' passed in the URL.

    I thought I could do this using jQuery but I'm not sure how to pass the function to a new page?

    Can anyone help me out?

    Thanks.

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Oct 31, 2011 @ 21:46
    Dan Okkels Brendstrup
    2

    There's surely a way to do this with jQuery, but you could also add a "selected" class to the appropriate list item via XSLT. I don't know what your code looks like, but something like this should work in the template/macro that renders your testimonials page:

    <xsl:variable name="selectedItem" select="umbraco.library:RequestQueryString('t')"/>
    <xsl:template match="Testimonial">
      <li>
        <xsl:if test="@id = $selectedItem">
          <xsl:attribute name="class">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="bodyText"/>
      </li>
    </xsl:template>
    ...and then ensure that li.selected is displayed via CSS or jQuery.
    I don't know if your testimLink is actually a node ID, but otherwise you can replace @id with the appropriate value to test for.
  • Rachel Skuse 88 posts 118 karma points
    Nov 01, 2011 @ 13:06
    Rachel Skuse
    0

    Hi Dan, thanks for your response - I can definitely see how this would work but the <li> already have a class defined..

    My code on the testimonials page is

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <ul id="accordion">
        <xsl:for-each select="$currentPage/node [@nodeTypeAlias='AccordianItem(Testimonial)']">
        <xsl:variable name="testimImage" select="./data[@alias='testimImage']"/>
        <xsl:variable name="testimZoomImage" select="./data[@alias='testimZoomImage']"/>
        <xsl:variable name="testimUniqueID" select="./data[@alias='testimUniqueID']"/>

          <li class="acItemTitle">
            <a name="t{$testimUniqueID}" href="?t=t{$testimUniqueID}" class="acItemTitleA">
              <span class="acItemSpan"><xsl:value-of select="@nodeName" /></span>
              <span class="acItemTitleASpan">Read more</span>
              <span class="clear"><xsl:comment>1</xsl:comment></span>
            </a>
            <div class="acItemContent">

        <!-- Testimonial Content here -->
        <div id="testimonial"></div>
        <!-- End Testimonial Content -->

        </div>
            <div class="clear"><xsl:comment>1</xsl:comment></div>
          </li>
        </xsl:for-each>
      </ul>
    </xsl:template>

    So I'm thinking maybe I need to use jQuery .addClass to make this work but I'm not too hot on jQuery!!

  • Rich Green 2246 posts 4008 karma points
    Nov 01, 2011 @ 13:09
    Rich Green
    1

    Hey Rachel,

    Dan's solution is correct, to add more than one class you just add all the classes you need back into the attribute

    <xsl:iftest="@id = $selectedItem">
         
    <xsl:attributename="class">acItemTitle selected</xsl:attribute>
      </xsl:if>

    Rich

  • Rachel Skuse 88 posts 118 karma points
    Nov 01, 2011 @ 13:26
    Rachel Skuse
    0

    Ah, thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft