Showing posts from July, 2011

XLST: Display an Image from a node reference and write it out if Tickbox is selected

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]> <xsl:stylesheet  version="1.0"  xmlns:xsl=" "  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=

A Latest News Macro using XSLT,

The Following Code can be placed in a Template or in a Macro for a user to place on any page. What this Macro does, is display only the last 2 news items, I have used it on the following sites, for example: Cindy-Lou photographer (link to follow) and SCSC (link to follow) The only bit that needs cahnged per project are: 1)  <xsl:variable name="maxItems" select="2"/> (highlighted below) --> This ensures only the lates 2 News Items are shown. 2) <xsl:if test= "@template = 1169"> (highlighted below) --> 1169 is the Template ID of my News Articles,  change 1169 to match the News Item template for your project.  <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]> <xsl:stylesheet   version="1.0"   xmlns:xsl=""   xmlns:msxml="urn:schemas-microsoft-com:xslt"   xmlns:u

Formating a Date in a Template, using umbraco.library:FormatDateTime

This bit of code gives you an example of how to format a date in a Template. <p><umbraco:Item field="newsDate" runat="server" xslt="umbraco.library:FormatDateTime({0}, 'MMMM d, yyyy')" ></umbraco:Item></p>

Formating Date, Using updatedDate in XSLT

1) This code shows you and Example of Formating the Date in XSLT <p><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'MMMM d, yyyy')"/> (Formating Options): Month MMMM = Full month name spelled out ('August') MMM = Abbreviated month name ('Aug') MM = 2 digit month ('08') %M = 1 or 2 digit month ('8') Day dddd = Full day of week ('Thursday') ddd = Abbreviated day of the week ('Thu') dd = 2 digit day ('06') d = 1 or 2 digit day ('6') Year y or yy = 2 digit year ('99') yyyy = 4 digit year ('1999') Hour h = 1 or 2 digit hour ('9') hh = 2 digit hour ('09') H = 24 hour ('21') Minute m = 1 or 2 digit minute ('3') mm = 2 digit minute('03') AM/PM tt = AM/PM RFC-1123 date-time r = the date-time following the RFC-1123 pattern For example: Wed, 02 Oct 2002 13:00:00 GMT

Assign a Umbraco Property/Field to a Vairable / IF statement / Testing the Value of a Umbraco Dropdown selction Box

The Following code a) Assigns a Variable "selectedValues" with the value of the umbraco Field "specialityList" b) Uses an If statment to Tests the Value of the Vairiable (the value is assignd by the user in Umbraco from a dropdown/combo box) c) The Umbraco function "contains(...,..)" test the value. <xsl:variable name="selectedValues" select="$currentPage/specialityList"/> <xsl:if test="contains($selectedValues, 'AHP')"> do something </xsl:if>

Removing Linebreaks from an Umbraco Field in xslt

This Example shows you how to Remove a Line Break from an Umbraco Field <p><xsl:value-of select="umbraco.library:ReplaceLineBreaks(newsIntro)" disable-output-escaping="yes"/> more..</p>