Posts

Showing posts from 2011

Validation: How to Validate a Google +1 Button - Plus 1 Button - in XHTM 1.0 Strict and how to align a google +1 buttin

The Google Plus 1 button does not Validate in XHTML Strict 1.0.  It also does not align properly.

Here is the solution:  (Step 1 and 2 deal with the Validation, step 3 deals with aligning the button)

1. Paste the following Code just before your opening <body> tag:

</script>
  <!-- Plus one Google -->
  <link rel="canonical" href="http://www.braveheartweddings.co.uk/" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js%22%3E%3C/script>

2. Paste the following where you want your button to go:

<div id="plusone"> <div class="g-plusone"></div> </div>
3. In you CSS, paste in the following (this will center align the button):

#plusone{text-align:center; margin:auto; margin-top:20px};

Umbraco: Display an Image, if one has been selected, using the Media Picker in an XSLT Macro

Umbraco: Display an Image, if one has been selected, using the Media Picker in an XSLT Macro

The follwoing XSLT file shows how to display an image from the Media Picker in Umbraco. 
The important bit is highlighted.


<?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 …

XSLT Umbraco - Get and Display an Image and Text from the Current Node

XSLT Umbraco - Get and Display an Image and Text from the Current Node

<?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 "…

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

This is a Simple Contact From done in C# .Net and also can be used in Umbraco.  Paste the code in to Visual Web Developer for a better view.

The important bits are coment in the second file.  One of the Commented out lines highlights how to get the mailto address from an Umbraco field.

The code Below includes the myContactForm.ascx.cs codebehind file and the myContactForm.ascx file.

1) The myContactForm.ascx file: 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactFormforPublications.ascx.cs" Inherits="usercontrols_ContactFormPublications" %>
<div class="contact-form" id="contactForm" runat="server">
    <h3>Request a Publication</h3>
    <div class='int'>
        <form runat="server">
        <asp:Panel DefaultButton="contactFormSubmit" runat="server">
        <fieldset>
            <div class='element name-…

Umbraco Macro - Only Write content Out if some content exists.

In the example below, the Macro will only write the content out if there is some content to write out.  For example if there is any content in the "CaseStudy" field write out the content in a DIV.  If not, do not display the DIV

<?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-resul…

DISABLE OUTPUTING - Use this when HTML Code is Showing rather than the Content when writing a Macro

Issue:  I am trying to write out an Image and some text from Content in a Macro, but hte HTML is showing


DO THIS:
<xsl:variable name="getimg" select="$currentPage/caseStudyImage"/>
  <div id="casestudyimg1">
   <xsl:value-of select="$getimg" disable-output-escaping="yes"/>
  </div>

INSTEAD OF THIS:


<xsl:variable name="getimg" select="$currentPage/caseStudyImage"/>
  <div id="casestudyimg1">
   <xsl:value-of select="$getimg" />
  </div>

Remove Unwanted Characters from Umbraco Nice URL

The simple way to remove unwanted characters from your URL is to change the rules umbraco uses when it generates the NiceUrl.
Edit the config/umbracoSettings.config
add a rule to remove all apostrophes from NiceUrls like so:
<urlReplacing>      ...      <charorg="'"></char><!-- replace ' with nothing -->      ...  </urlReplacing>Note: The contents of the "org" attribute is replaced with the contents of the element, here's another example:
<charorg="+">plus</char><!-- replace + with the word plus -->

Umbraco Email Notifications - File Location and Default Email Address for Notifications

A) WHERE Does the 'to' email address go?1) There is a setting in the config/umbracosettings.config
        <notifications>
            <!-- the email that should be used as from mail when umbraco sends a notification -->
            <email>your@email.here</email>
        </notifications>


B) Where to change the Content of the Email: 1 ) en.xml file: (umbraco\config\lang):

Complex XSLT Macro for embedding an I frame - using Paramaters

(http://forum.umbraco.org/yaf_postst4641_cant-embed-html-in-page.aspx)

Create a new macro and in it create 3 parameters "location", "width" and "height".
Check the "Use in editor" checkbox. Now create a xslt that looks something like this:


<?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"
    exclude-result-prefixes="msxml umbraco.library">


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

<xsl:param name="currentPage"/>

<xsl:variable name="location" select="/macro/location"/>
<xsl:variable name="width" select="/macro/widt…

Simple XSLT Macro for embedding an I frame:

Simple XSLT Macro for embedding an I frame: 1) Create a New "Clean" xslt - ensure Create Macro is Ticked. 2) Where the XSLT reads: <!-- start writing XSLT --> - just paste in your IFRAME (highlighted below) 3) Go to the new Macro and tick "Use in Editor", this will allow it in the user drop down. <?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:Exs…

Umbraco - Using GetPreValueAsString to Return the String of a Field and not its value

If you have a field in Umbraco that is getting returned as a number instead of the name, see the highlighted text below.  1 - In a Macro . 2 - In a Template.

1.  IN A XSLT MACRO:

<?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:PS.XSLTsearch="urn:PS.XSLTsearch"
  exclude-result-pre…

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="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="…

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="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:umbraco.library=&quo…

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"/>....read more..</p>

IIS - Server Issue - Flash not showing or Flv not showing or other media not showing.

If you have an issue with certain media not showing on a web site, it may be because IIS needs to be informed of the type of file.

Test: If you can download the site to a local machine, disconnect it from the Internet and still view the videos without issue, this proves that the files are being either: 1) blocked by a firewall 2) a  proxy issue - if it's a proxy issue add the details to the web config 3) Because IIS does not know about the File Types/

This example shows how to add .flv files in to IIS so that the run from the server.

Adding .flv MIME type in IIS

1) Select the site to configure in IIS, right click and select "Properties"
2) Under HTTP Headers Tab, select "File Types" under the MIME Map section and select "New Type"
3) Type ".flv" as the associated extension and "video/x-flv" as the content type.
4) Select "OK"


Update: IIS 6 not displaying Office 2007 files, .docx ect. HTTP Error 404 – File or directory no…

.net User Control - Exporting to Umbraco

1) In Visual Studio Build the Application
2) Copy The .User Cotrol .ascx and .dll from your Application to the dll folder of your Umbraco install
3) In Umbraco in your Master Template, surroind your Content Placeholder a Form declaration:
<form runat="server" id="frmMain">                <asp:ContentPlaceHolder Id="masterContent" runat="server">
                <!-- Insert default "masterContent" markup here -->
                </asp:ContentPlaceHolder>
</form>4) In Umbraco Developer Section Create a new Macro
5) Inset the Macro in to your Template Code and/or as a Macro for the User

.Net User Control Part 2 - Redirect on Drop Down Selection

1) On your User control .ascx, change the first line:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DropDownUserControl.ascx.cs" Inherits="WebApplication1.DropDownUserControl.WebUserControl1" %>

to:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DropDownUserControl.ascx.cs" Inherits="WebApplication1.DropDownUserControl.WebUserControl1" %>

2) Add a Function call for example "goToCourses" to the Code Behind page of the User Control: (I'll redirect to Yahoo just to test it)


namespace WebApplication1.DropDownUserControl
{
    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        public void Click(Object s, EventArgs e)
        {
            Response.Redirect("http://yahoo.co.uk/");
        }

    }
}

3) In your User Control add the AutoPostBack

.Net - Creating a User Control Part 1

1) Open your .Net Application.
2) in the SOLUTION EXPLORER create a New Folder (give it the name of the User Contro: DropDownUserControll)
3) in the New Folder, create a .Net User Control (give it the name of the User Control: DropDownUserControl)
4) Reference the User Control in your Default.ascx:

<%@ Register TagPrefix="CDDM" TagName="MDDropDown" Src="~/DropDownUserControl/DropDownUserControl.ascx" %>@ Register TagPrefix="CDDM" TagName="MDDropDown" Src="~/DropDownUserControl/DropDownUserControl.ascx" %>

5) Add the following code to the User Control ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DropDownUserControl.ascx.cs"Inherits="WebApplication1.DropDownUserControl.WebUserControl1" %>

<asp:DropDownList ID="DropDownList1" runat="server"  AutoPostBack="True" OnSelectedIndexChanged="Click">
     <asp:Lis…