Copied to clipboard

Flag this post as spam?

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


  • dan s 4 posts 24 karma points
    Sep 24, 2010 @ 10:57
    dan s
    0

    Cant access newsitems - xlst macro

    Hi Guys

    Im a complete newbie with umbraco although i am a .net developer and this is also my first time round with xslt.

    I was able to follow the tutorials to create a a news area section or in my case a latest feature section with marco to display them but heres my problem.

    My site is structured like so

    So under the main site, authors can create general latest features, which will display on the main home page of kim.aspx, but then, they can also create new items specific for each sub web / area ie business, collections etc etc. (Each folder represents a home page for a site)

    I have created the following macro, which will get items under the business area but this is where the problem starts, firstly, it wont get the items top level, ie under / for kim.aspx.  Im sure this is probably something i need to change regarding the level, and i may need two macros to do this.  The other problem is that when i try to merge the template used for displaying the features, with my homepage template, so i can display the features under each home page, it throws a paser error but i cant find out what the error is.

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

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

    <xsl:param name="currentPage"/>
    <!-- create parameter number of items so user can set how many to display -->
    <xsl:variable name="numberOfItems" select="/macro/numberOfItems"/>
    <!-- create parameter to hold width and height which can be set in macro on template -->
    <xsl:variable name="imageWidth" select="/macro/imageWidth" />
    <xsl:variable name="imageHeight" select="/macro/imageHeigth" />
       
    <xsl:variable name="level" select="1"/>
        
    <xsl:template match="/">
      
    <!-- The fun starts here -->  
    <xsl:for-each select="$currentPage/descendant-or-self::* [@isDoc and string(umbracoNaviHide) != '1']">
    <!-- order by the updated date descending, so it shows most recent -->
      <xsl:sort select="@updateDate" order="descending"/>
      <!-- read in number of items to display from our macro on template page -->
      <xsl:if test="position() &lt;= $numberOfItems">
    <table class="featuretable">
      <tr>
        <td id="featureheader" class="featureheader"><xsl:value-of select="featureTitle"/></td>
        <td rowspan="3" id="featurespacer" class="featurespacer"></td>
        <td rowspan="3" id="featurecontent" class="featurecontent"><xsl:value-of select="bodyText" disable-output-escaping="yes" /></td>
      </tr>
      <tr>
        <td id="featureheadspacer" class="featureheadspacer"></td>
      </tr>
      <tr>
        <td id="featureimg" class="featureimg">
          <xsl:variable name="media" select="umbraco.library:GetMedia(featureImage, 0)" />
          <!-- read in height and width from our macro on template page -->
          <img src="{$media/umbracoFile}" width="{$imageWidth}px" height="{$imageHeight}px" />  
        </td>
      </tr>
    </table>
      </xsl:if>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    Heres the code for the featuremaster template

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:content ContentPlaceHolderId="ContentPlaceHolderDefault" runat="server">
      <div id="featureAreaHeader" class="featureAreaPageHeader">
     <umbraco:Item field="pageHeader" runat="server"></umbraco:Item>
      </div>
        <br/>
          <div id="features">          
            <umbraco:Macro numberOfItems="5" imageHeight="117" imageWidth="200" Alias="FeaturesList" runat="server"></umbraco:Macro>
          </div>
    </asp:content>

    Any help would be really appreciated as im really stuck and have tried lots of things but getting no where fast.

    THanks

    Dan

     

Please Sign in or register to post replies

Write your reply to:

Draft