Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-9867

[New Search] Improve the sort helper to easily make a dropdown

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • 4.9.0
    • 4.2.0
    • None

      in the demo skin maybe

          [CMS-9867] [New Search] Improve the sort helper to easily make a dropdown

          Sample code.
          Please note all the hacks required! (current sort, eval in js!)

          <!-- +
                   | Template for results sort
                   + -->
              <xsl:template name="sorts">
                  <xsl:if test="count(/search/form/sorts/sort) > 0">
                      <div class="ametys-results-sort-wrapper float-right">
                          <span class="ametys-results-sort__title"><i18n:text i18n:key="PLUGINS_WEB_SERVICE_SEARCH_VIEW_SORT_BY" i18n:catalogue="plugin.web"/></span>
                          <xsl:call-template name="sorts-list"/>
                      </div>
                  </xsl:if>
              </xsl:template>
              
              <xsl:template name="sorts-list">
                  <select class="ametys-results-sort__control" name="sort">
                  	<xsl:attribute name="onchange">eval("function a(){" + this.options[this.selectedIndex].getAttribute('onselect') + "}"); try { a.call(this); } catch(e) { }; return true;</xsl:attribute>
                  
                      <xsl:for-each select="/search/form/sorts/sort">
                          <option value="{@name}">
                          	<xsl:attribute name="onselect"><xsl:call-template name="search-js-sort"/></xsl:attribute>
                          	
                              <xsl:call-template name="sort-element-selected-or-not"/>
                          </option>
                      </xsl:for-each>
                  </select>
                  <xsl:for-each select="/search/form/sorts/sort[@selected]">
          	        <xsl:call-template name="sort-hidden-input-for-selected"/>
                  </xsl:for-each>
              </xsl:template>
              
              <xsl:template name="sort-element-selected-or-not">
             		<xsl:if test="@selected"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
             		<xsl:value-of select="label"/>
              </xsl:template>
          

          Raphaël Franchet added a comment - Sample code. Please note all the hacks required! (current sort, eval in js!) <!-- + | Template for results sort + --> <xsl:template name= "sorts" > <xsl: if test= "count(/search/form/sorts/sort) > 0" > <div class= "ametys-results-sort-wrapper float -right" > <span class= "ametys-results-sort__title" ><i18n:text i18n:key= "PLUGINS_WEB_SERVICE_SEARCH_VIEW_SORT_BY" i18n:catalogue= "plugin.web" /></span> <xsl:call-template name= "sorts-list" /> </div> </xsl: if > </xsl:template> <xsl:template name= "sorts-list" > <select class= "ametys-results-sort__control" name= "sort" > <xsl:attribute name= "onchange" >eval( "function a(){" + this .options[ this .selectedIndex].getAttribute( 'onselect' ) + "}" ); try { a.call( this ); } catch (e) { }; return true ;</xsl:attribute> <xsl: for -each select= "/search/form/sorts/sort" > <option value= "{@name}" > <xsl:attribute name= "onselect" ><xsl:call-template name= "search-js-sort" /></xsl:attribute> <xsl:call-template name= "sort-element-selected-or-not" /> </option> </xsl: for -each> </select> <xsl: for -each select= "/search/form/sorts/sort[@selected]" > <xsl:call-template name= "sort-hidden-input- for -selected" /> </xsl: for -each> </xsl:template> <xsl:template name= "sort-element-selected-or-not" > <xsl: if test= "@selected" ><xsl:attribute name= "selected" >selected</xsl:attribute></xsl: if > <xsl:value-of select= "label" /> </xsl:template>

            Unassigned Unassigned
            llopez Laure Lopez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: