Changeset 34300
- Timestamp:
- 2020-07-28T17:18:44+12:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/wmtb/transform/pages/home.xsl
r34277 r34300 64 64 <tbody class="wsite-multicol-tbody"> 65 65 <tr class="wsite-multicol-tr"> 66 <xsl:call-template name="collectionAndGroupLinks"/> 66 <!-- <xsl:call-template name="collectionAndGroupLinks"/> --> 67 68 <!-- output the groups, the following outputs them column wise --> 69 <xsl:apply-templates select="groupList/group" mode="displayGroupInfo" /> 70 <!-- then output the collectionList in a final column --> 71 <xsl:apply-templates select="collectionList/collection" mode="displayCollInfo" /> 67 72 </tr> 73 68 74 </tbody> 69 75 </table> … … 88 94 89 95 <xsl:template name="collectionsList"> 90 <!-- for every collection in the library -->96 <!-- for every collection in the library --> 91 97 <xsl:for-each select="./collectionList/collection"> 92 98 <xsl:call-template name="collDescription"/> 93 99 </xsl:for-each> 94 100 </xsl:template> 95 96 <xsl:template name="collDescription"> 101 102 <!-- 103 Template has match and name attributes allowing this to be called with both 104 apply-templates and call-template. 105 https://stackoverflow.com/questions/6478163/can-an-xslt-template-carry-both-name-and-match-attributes 106 --> 107 <xsl:template match="collection" name="collDescription" mode="displayColl"> 97 108 <xsl:variable name="collectionFolder" select="@name"/> 98 109 <xsl:variable name="collectionName" select="displayItemList/displayItem[@name='name']"/> … … 136 147 <td class="wsite-multicol-col" style="width:33.333333333333%; padding:0 15px;"> 137 148 <xsl:if test="name() = 'collection'"> 138 139 </xsl:if>140 <xsl:if test="name() = 'group'">141 142 </xsl:if>149 <xsl:call-template name="collDescription"/> 150 </xsl:if> 151 <xsl:if test="name() = 'group'"> 152 <xsl:call-template name="customGroupDescription"/> 153 </xsl:if> 143 154 </td> 144 155 </xsl:for-each> 145 146 </xsl:template> 156 </xsl:template> 157 158 <!-- https://stackoverflow.com/questions/93511/counter-inside-xslfor-each-loop 159 will not work, since we have an if-statement inside the for loop to filter for groups. 160 Instead, counting only the groups using Borodin's solution (still xslt 1.0) from 161 https://stackoverflow.com/questions/16504727/increment-counter-in-xslt-1-0 works. 162 163 While that gives us a proper counter not dependent on position(), it doesn't solve 164 that we need to open a tag (td) on odd count and close it on even. 165 For that, the solution is at: 166 https://stackoverflow.com/questions/17992481/xsl-wrap-every-2-items-in-the-for-each-with-a-div 167 168 General: https://stackoverflow.com/questions/4478045/what-are-the-differences-between-call-template-and-apply-templates-in-xsl 169 --> 170 <xsl:template match="group" mode="displayGroupInfo"> 171 <xsl:variable name="counter"><xsl:value-of select="1+count(preceding-sibling::group)])"/></xsl:variable> 172 <xsl:if test="($counter mod 2) = 1"> 173 <td class="wsite-multicol-col" style="width:33.333333333333%; padding:0 15px;"> 174 <xsl:apply-templates select=". | following-sibling::group[1]" /> 175 <!-- calls the template match="group" without mode this time --> 176 </td> 177 </xsl:if> 178 </xsl:template> 179 180 <!-- We want collections to appear in a separate and single column. 181 So we don't do even odd columns here. --> 182 <xsl:template match="collection" mode="displayCollInfo"> 183 <!--<xsl:variable name="counter"><xsl:value-of select="1+count(preceding-sibling::collection)])"/></xsl:variable> 184 <xsl:if test="($counter mod 2) = 1">--> 185 <td class="wsite-multicol-col" style="width:33.333333333333%; padding:0 15px;"> 186 <!--<xsl:apply-templates select=". | following-sibling::collection[1]" />--> 187 <xsl:apply-templates select="." mode="displayColl"/> 188 <!-- why does calling the template match="collection" without some mode 189 attr this time NOT work? --> 190 </td> 191 <!--</xsl:if>--> 192 </xsl:template> 193 147 194 <xsl:template match="/page/xsltparams"> 148 195 <!-- suppress xsltparam block in page --> … … 150 197 151 198 <!-- Modified version of <gslib:groupLinkWithImage/>--> 152 <xsl:template name="customGroupDescription"> 199 <!-- 200 Template has match and name attributes allowing this to be called with both 201 apply-templates and call-template. 202 https://stackoverflow.com/questions/6478163/can-an-xslt-template-carry-both-name-and-match-attributes 203 --> 204 <xsl:template match="group" name="customGroupDescription"> 205 153 206 <xsl:variable name="short"><xsl:value-of select="shortDescription"/></xsl:variable> 154 207 <xsl:variable name="desc"><xsl:value-of select="description"/></xsl:variable>
Note:
See TracChangeset
for help on using the changeset viewer.