Copied to clipboard

Flag this post as spam?

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


  • Vincent DeCapite 64 posts 83 karma points
    Jun 28, 2011 @ 14:20
    Vincent DeCapite
    0

    XSLT Showing All Categories Instead of just certain ones

    Hi,

    I have a quick question on an XSLT that we are using for our video library function. The problem is we have our video library divided up into two main categories that have sub categories under them. The problem is when the page loads, all categories show instead of just the ones for that selected page. I have been playing with the XSLT and CSS but I can't find anything that controls this.

    Any help would be greatly appreciated. Below is the XSLT I am using for the library

     

    <?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:tagsLib="urn:tagsLib" xmlns:wsc.library="urn:wsc.library"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib wsc.library ">


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

    <xsl:param name="currentPage"/>
    <xsl:variable name="videoID" select="umbraco.library:Request('video')" />
    <xsl:variable name="videoLibrary" select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'VideoLibrary']" />
    <xsl:variable name="videoGroups" select="$videoLibrary/node [@nodeTypeAlias = 'VideoGroup']" />
    <xsl:variable name="videoGroupRaw">
    <xsl:choose>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoGroup'">
    <xsl:copy-of select="$currentPage" />
    </xsl:when>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoCategory'">
    <xsl:copy-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'VideoGroup']" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$videoGroups[1]" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="videoGroup" select="msxml:node-set($videoGroupRaw)/node" />
    <xsl:variable name="videoCategoriesRaw">
    <xsl:choose>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoGroup'">
    <xsl:copy-of select="$currentPage/node [@nodeTypeAlias = 'VideoCategory']" />
    </xsl:when>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoCategory'">
    <xsl:copy-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'VideoGroup']/node [@nodeTypeAlias = 'VideoCategory']" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$currentPage/node [@nodeTypeAlias = 'VideoGroup']/node [@nodeTypeAlias = 'VideoCategory']" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="videoCategories" select="msxml:node-set($videoCategoriesRaw)/node" />
    <xsl:variable name="videoCategoryRaw">
    <xsl:choose>
    <!--
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoGroup'">
    <xsl:copy-of select="$currentPage/node [@nodeTypeAlias = 'VideoCategory'][1]" />
    </xsl:when>
    -->
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoCategory'">
    <xsl:copy-of select="$currentPage" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$videoCategories[1]" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="videoCategory" select="msxml:node-set($videoCategoryRaw)/node" />
    <xsl:variable name="videosRaw">
    <xsl:choose>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoLibrary'">
    <xsl:value-of select="$currentPage//node [@nodeTypeAlias = 'VideoCategory'][1]/data [@alias = 'videos']" />
    </xsl:when>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoGroup'">
    <xsl:value-of select="$currentPage/node [@nodeTypeAlias = 'VideoCategory'][1]/data [@alias = 'videos']" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$currentPage/data [@alias = 'videos']" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <xsl:variable name="videos" select="umbraco.library:Split($videosRaw, ',')//value" />

    <xsl:variable name="videoUrl">
    <xsl:choose>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoLibrary'">
    <xsl:value-of select="$videoGroup/node [@nodeTypeAlias = 'VideoCategory'][1]/data [@alias = 'videos']" />
    </xsl:when>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'VideoGroup'">
    <xsl:value-of select="$currentPage/node [@nodeTypeAlias = 'VideoCategory'][1]/data [@alias = 'videos']" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$currentPage/data [@alias = 'videos']" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('VideoLibraryCSS', '/inc/style/videolibrary.css')" />

    <xsl:value-of select="$videoLibrary/data [@alias = 'bodyText']" disable-output-escaping="yes" />

    <ul class="groups">
    <xsl:for-each select="$videoGroups">
    <xsl:if test="number(@id)">
    <li class="group{position()}">
    <xsl:attribute name="class">
    <xsl:text>group</xsl:text>
    <xsl:value-of select="position()" />
    <xsl:if test="current()/@id = $videoGroup/@id">
    <xsl:text> selected</xsl:text>
    </xsl:if>
    </xsl:attribute>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="data [@alias = 'metaPageTitle']" /></a>
    </li>
    </xsl:if>
    </xsl:for-each>
    </ul>

    <div class="tabContent">

    <ul class="categories clearfix">
    <xsl:for-each select="$videoCategories">
    <li>
    <xsl:if test="@id = $videoCategory/@id">
    <xsl:attribute name="class">
    <xsl:text>selected</xsl:text>
    </xsl:attribute>
    </xsl:if>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="data [@alias = 'metaPageTitle']" /></a>
    </li>
    </xsl:for-each>
    </ul>
    <br clear="all" />
    <div class="videos">
    <ul class="videosScroll">
    <xsl:for-each select="$videos">
    <xsl:if test="number(current())">
    <xsl:variable name="video" select="umbraco.library:GetMedia(current(), 'true')" />
    <xsl:variable name="image" select="$video//node [data [@alias = 'umbracoExtension'] = 'jpg']/data [@alias = 'umbracoFile']" />
    <li>
    <a href="{umbraco.library:Replace(umbraco.library:NiceUrl($videoCategory/@id), '.aspx', concat('/', current(), '.aspx'))}">
    <span class="title"><xsl:value-of select="$video/data [@alias = 'videoTitle']" /></span>
    <span class="thumb">
    <span class="mask">
    <xsl:if test="$image != ''">
    <img src="/umbraco/imagegen.ashx?width=85&amp;image={$image}" alt="{$video/data [@alias = 'videoTitle']}" width="85" height="85" />
    </xsl:if>
    </span>
    </span>
    </a>
    </li>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </div>
    <div class="video">
    <xsl:choose>
    <xsl:when test="$videoID != ''">
    <xsl:call-template name="Video">
    <xsl:with-param name="videoID" select="$videoID" />
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="Video">
    <xsl:with-param name="videoID" select="$videos[1]" />
    </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>
    </div>

    </div>

    </xsl:template>

    <xsl:template name="Video">
    <xsl:param name="videoID" />
    <xsl:if test="number($videoID)">
    <xsl:variable name="video" select="umbraco.library:GetMedia($videoID, 'true')" />
    <xsl:variable name="flv" select="$video//node [data [@alias = 'umbracoExtension'] = 'flv']/data [@alias = 'umbracoFile']" />
    <xsl:variable name="mov" select="$video//node [data [@alias = 'umbracoExtension'] = 'mov']/data [@alias = 'umbracoFile']" />
    <xsl:variable name="blackberry" select="$video//node [data [@alias = 'umbracoExtension'] = '3gp']/data [@alias = 'umbracoFile']" />
    <!-- NEW CODE ADDED DECEMBER 13, 2010 WHITESPACE DECAPITE -->
    <xsl:variable name="mp4" select="$video//node [data [@alias = 'umbracoExtension'] = 'mp4']/data [@alias = 'umbracoFile']" />
    <xsl:variable name="wmv" select="$video//node [data [@alias = 'umbracoExtension'] = 'wmv']/data [@alias = 'umbracoFile']" />

    <h2>
    <xsl:value-of select="$video/data [@alias = 'videoTitle']" />
    </h2>
    <!-- OLD CODE REMOVED DECEMBER 13, 2010 WHITESPACE DECAPITE
    <h2><xsl:value-of select="$video/data [@alias = 'title']" /></h2> -->
    <xsl:if test="$flv != ''">
    <div id="flashVideo">
    <xsl:value-of select="$flv" />
    </div>
    <script type="text/javascript">
    var video = '<xsl:value-of select="$flv" />';
    <![CDATA[
    var flashvars = {video: video};
    var params = { wmode:'transparent', allowFullScreen:'true', bgcolor:'#000000'};
    var attributes = {};

    swfobject.embedSWF('/elements/flash/videoplayer.swf', 'flashVideo', '473', '289', '9.0.0', '', flashvars, params, attributes);
    ]]>
    </script>
    </xsl:if>
    <!-- OLD CODE REMOVED DECEMBER 13, 2010 WHITESPACE DECAPITE
    <h2>Viewing Options</h2>
    <dl class="downloads">
    <dt>Download for:</dt>
    <xsl:if test="$mov != ''">
    <dd><a href="{$mov}" target="_blank">iPhone</a></dd>
    </xsl:if>
    <xsl:if test="$blackberry != ''">
    <dd><a href="{$blackberry}" target="_blank">Blackberry</a></dd>
    </xsl:if>
    </dl>
    -->
    <!-- NEW CODE ADDED DECEMBER 13, 2010 WHITESPACE DECAPITE -->
    <table class="video_download" cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
    <th align="left" colspan="2">Download Video</th>
    </tr>
    <xsl:call-template name="DownloadRow">
    <xsl:with-param name="url" select="$mov" />
    <xsl:with-param name="type" select="'mov'" />
    <xsl:with-param name="title" select="'iPhone'" />
    </xsl:call-template>
    <xsl:call-template name="DownloadRow">
    <xsl:with-param name="url" select="$blackberry" />
    <xsl:with-param name="type" select="'blackberry'" />
    <xsl:with-param name="title" select="'Blackberry'" />
    </xsl:call-template>
    <xsl:call-template name="DownloadRow">
    <xsl:with-param name="url" select="$wmv" />
    <xsl:with-param name="type" select="'wmv'" />
    <xsl:with-param name="title" select="'Windows'" />
    </xsl:call-template>
    </table>
    <br />
    <p><a href="{umbraco.library:Replace(umbraco.library:NiceUrl($videoCategory/@id), '.aspx', concat('/', $videoID, '.aspx'))}">Unique URL</a></p>
    </xsl:if>
    </xsl:template>
    <!-- NEW CODE ADDED DECEMBER 13, 2010 WHITESPACE DECAPITE -->
    <!-- DOWNLOAD ROW -->
    <xsl:template name="DownloadRow">
    <xsl:param name="url" />
    <xsl:param name="type" />
    <xsl:param name="title" />

    <xsl:if test="$url != ''">
    <tr>
    <td class="download {$type}">
    <a href="{$url}">
    <img src="/elements/spacer.gif" />
    <xsl:value-of select="$title" />
    </a>
    </td>
    <td class="instructions">
    <a href="/clinical-resources/download-instructions.aspx#{$type}" target="_blank">Download Instructions</a>
    </td>
    </tr>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft