Copied to clipboard

Flag this post as spam?

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


  • Rick van der Zwart 8 posts 28 karma points
    Mar 01, 2013 @ 10:09
    Rick van der Zwart
    0

    Changing XSLT conditions with buttons?

    Hello, everybody. It's me again.

    After finally getting my XSLT to work, I have been given another assignment to my... assignment. However, this time, I'm completely stumped even with help from Google and my colleagues.

    As a brief summary, my XML file contains a large list of products that you could find on a webshop. I have to be able to list them all when the page loads, and filter them to only show Dutch products by using a button.

    I have been able to filter the products to only show Dutch products, but I have no idea how to activate this by using a button. I would really appreciate it if somebody could help me with this problem.

    Here is my XSLT:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:variable name="MyFeed" select="umbraco.library:GetXmlDocumentByUrl('http://shop.voetbalshirts.com/content/files/exportimport/froogle_7679424322.xml')" />
      <xsl:for-each select="$MyFeed/rss/channel/item">
              <xsl:variable name="productcondition" select="*[local-name()='product_type']" />
              <xsl:if test="contains($productcondition, 'Nederland')">

                  <div style="padding: 10px;" align="center">
                      <span style="font-weight:bold"><xsl:value-of select="title"/></span><br />
                      <xsl:variable name="productlink" select="*[local-name()='link']" />
                      <a>
                      <xsl:attribute name="href"><xsl:value-of select="$productlink"/></xsl:attribute>
                      <xsl:attribute name="target">_blank</xsl:attribute>
                      <img>
                          <xsl:variable name="image" select="*[local-name()='image_link']" />
                          <xsl:attribute name="src"><xsl:value-of select="$image"/></xsl:attribute>
                      </img><br />
                      </a>
                      <xsl:value-of select="description" disable-output-escaping="yes"/>
                  </div>
              </xsl:if>
      </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    The bold piece of code is supposed to be off when the page loads, and must be activated by pressing the button.

  • Claushingebjerg 939 posts 2574 karma points
    Mar 26, 2013 @ 15:40
    Claushingebjerg
    0

    You could do it using javascript...

    If you want to do it in the xml, i requires a page reload, as the xslt is rendered on the server not in the browser.
    You could do it by sending a query string, and then reading this in your xslt and using this to filter the list.

    like:
    <a href="mypage.aspx?filter=dutch">

    and then using 

    umbraco.library:RequestQueryString('filter') 

    in your xslt.

Please Sign in or register to post replies

Write your reply to:

Draft