Copied to clipboard

Flag this post as spam?

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


  • Klaus 47 posts 67 karma points
    Jul 13, 2011 @ 11:58
    Klaus
    0

    Put some XLST inside a Accordion menu

    Hallo, 

    on my webpage http://graver.eduaider.com/produktinformation/roegroer.aspx I would like an accordion menu displaying some XSLT stuff (Issuu pdf). I have this code inside my xslt page:


    <xsl:if test="$currentPage/*[not(isDoc) and local-name() = $field]/value != ''">
    <div id="accordion" class="accordionWrapper">
      <div class="set">
          <div class="title">Tryk her for at ekspandere</div>
            <div class="content">
            <xsl:value-of select="issuu:GetEmbedCode($currentPage/*[not(isDoc) and local-name() = $field]/value/@dataTypeId, $currentPage/*[not(isDoc) and local-name() = $field]/value, $width, $height)" disable-output-escaping="yes"/>
          </div>
        </div>
      </div>
     </xsl:if>  
              

    <script language="javascript" type="text/javascript">
    $(document).ready(function() {

                   $("#accordion").msAccordion({defaultid:1, vertical:true});
                   }
                   )
    </script>
     

    The only problem is, that only the first item opens.

    Any suggestions? Should i use for-each?

    //Klaus

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2011 @ 18:48
    Lee Kelleher
    0

    Hi Klaus,

    One problem is that you have multiple tags with the same ID name "accordion" ... each of these should be unique - otherwise which one is the accordion trying to access/use? (The first one it comes to, right?)  I'd append a number to each of them "accordion1", "accordion2" and "accordion3"

    Then switch the jQuery call to use the class name selection, rather than the ID name.

    $('.accordionWrapper').msAccordion( { defaultid: 1, vertical: true } );

    Good luck!

    Cheers, Lee.

  • Klaus 47 posts 67 karma points
    Jul 13, 2011 @ 19:16
    Klaus
    0

    Hello Lee,

    Thanks very much for your reply. I am a total novice in this area - could you explain me how to give the accordion unique tags? How you append a number to each of them?

    Thanks

    Klaus

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2011 @ 19:21
    Lee Kelleher
    0

    Hi Klaus,

    Sure, no worries.  In your XSLT are you writing out 3 separate accordion tags? If so, then change the ID name of each one:

    <div id="accordion1" class="accordionWrapper">
    <div id="accordion2" class="accordionWrapper">
    <div id="accordion3" class="accordionWrapper">

    Cheers, Lee.

  • Klaus 47 posts 67 karma points
    Jul 13, 2011 @ 19:57
    Klaus
    0

    Hallo again,

    this is my XSLT:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:issuu="urn:issuu"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets issuu ">


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

    <xsl:param name="currentPage"/>
    <xsl:variable name="field" select="/macro/field" />
    <xsl:variable name="width" select="/macro/cssWidth" />
    <xsl:variable name="height" select="/macro/cssHeight" />
        
    <xsl:template match="/">
      <div id="accordion" class="accordionWrapper">
       <xsl:for-each select="$currentPage/*[not(isDoc) and local-name() = $field]/value">
         <div id="" class="set">
           <div class="title">Tryk her for at ekspandere</div>
               <div class="content">
                 <xsl:value-of select="issuu:GetEmbedCode($currentPage/*[not(isDoc) and local-name() = $field]/value/@dataTypeId, $currentPage/*[not(isDoc) and local-name() = $field]/value, $width, $height)" disable-output-escaping="yes"/>
                </div>
            </div>
                  </xsl:for-each>
        </div>
    <script language="javascript" type="text/javascript">
    $(document).ready(function() {

                   $("#accordion").msAccordion({defaultid:1, vertical:true});
                   }
                   )
    </script>


    </xsl:template>

    </xsl:stylesheet>


  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2011 @ 20:04
    Lee Kelleher
    0

    Ah, are you re-using the same Macro 3 times? If so, is the "field" value different for each one?

    Then try this:

    <div id="accordion-{$field}" class="accordionWrapper">

    Cheers, Lee.

  • Klaus 47 posts 67 karma points
    Jul 13, 2011 @ 20:10
    Klaus
    0

    Hi Lee,

     

    I actually got it working by using an If statement instead.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:issuu="urn:issuu"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets issuu ">


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

    <xsl:param name="currentPage"/>
    <xsl:variable name="field" select="/macro/field" />
    <xsl:variable name="width" select="/macro/cssWidth" />
    <xsl:variable name="height" select="/macro/cssHeight" />
        
    <xsl:template match="/">
      <div id="accordion" class="accordionWrapper">
         <div id="" class="set">
           <div class="title">Tryk her for at ekspandere</div>
               <div class="content">
                    <xsl:if test="$currentPage/*[not(isDoc) and local-name() = $field]/value != ''">
                 <xsl:value-of select="issuu:GetEmbedCode($currentPage/*[not(isDoc) and local-name() = $field]/value/@dataTypeId, $currentPage/*[not(isDoc) and local-name() = $field]/value, $width, $height)" disable-output-escaping="yes"/>
                       </xsl:if>
                 </div>
            </div>

        </div>
    <script language="javascript" type="text/javascript">
    $(document).ready(function() {

                   $("#accordion").msAccordion({defaultid:1, vertical:true});
                   }
                   )
    </script>


    </xsl:template>

    </xsl:stylesheet>

    Can you tell me why?

     

    /Klaus

Please Sign in or register to post replies

Write your reply to:

Draft