Nibble

Archive for the 'config' Category


/config/xsltExtensions.config 3

Another config file (check here for /config/Dashboard.config) that can be found in the /config folder of umbraco is the xslExtensions.config.

This file can be used to setup custom xslt extensions.

If you are not familiar with xslt extensions here is a brief intro:

With xslt extensions you can call static .net methods from xslt.

When editing an xslt file and inserting a value.

xsltextensions1

You get the option to “get extensions”.

xsltextensions2

Hitting the button will display a new modal that will list all xslt extensions and their methods.

Default umbraco has a couple of xslt extensions .

xsltextensions3

The most used one would probably be umbraco.library:NiceUrl(Int32 nodeID) , this takes a node id and will output the url of that node.

xsltextensions4

 

Using /config/xslExtensions.config you can also add custom xslt extensions.

Lets look at an example, the blog package for umbraco 4 comes with an xslt extension to get the gravatar image based on an email address.

So step 1 is to write the .net code that can be used. This is just a static method.

 

using System;
using System.Collections.Generic;
using System.Web;
 
namespace Umlaut.Umb.Blog
{
    public class BlogLibrary
    {
        /// <summary>
        /// Gets the gravatar.
        /// </summary>
        /// <param name=”email”>The email.</param>
        /// <param name=”size”>The size.</param>
        /// <param name=”defaultImage”>The default image.</param>
        /// <returns></returns>
        public static string getGravatar(string email, int size, string defaultImage)
        {
            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] result = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(email));
 
            System.Text.StringBuilder hash = new System.Text.StringBuilder();
            for (int i = 0; i < result.Length; i++)
                hash.Append(result[i].ToString(“x2″));
 
            System.Text.StringBuilder image = new System.Text.StringBuilder();
 
            image.Append(“http://www.gravatar.com/avatar.php?”);
            image.Append(“gravatar_id=” + hash.ToString());
            image.Append(“&amp;rating=G”);
            image.Append(“&amp;size=” + size.ToString());
            image.Append(“&amp;default=”);
            image.Append(System.Web.HttpContext.Current.Server.UrlEncode(defaultImage));
           
 
            return image.ToString();
        }
    }
}

 

Next step (after dropping the assembly in the bin) is to setup the xslExtensions.config file.

<?xml version=”1.0″ encoding=”utf-8″?>
<XsltExtensions>
  <ext assembly=”\bin\Umlaut.Umb.Blog” type=”Umlaut.Umb.Blog.BlogLibrary” alias=”BlogLibrary”>
  </ext>
</XsltExtensions>

So you need a new ‘ext’ node with the following attributes:

  • assembly
  • type
  • alias

If the settings are correct it should appear (with the alias setup in the config file) in the xslt extensions modal

xsltextensions5

Last thing todo before you can use it is to declare the namespace.

<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:BlogLibrary=”urn:BlogLibrary”
    exclude-result-prefixes=”msxml umbraco.library BlogLibrary”>

Enabling the script editor 3

This feature was introduced at codegarden 07 as a new feature in v3 but is was disabled in the release because of some issues with cross browser compatibility ( and maybe other bugs, …). I noticed that it works fine in firefox but don’t use it with ie.

Before:

image

After:

image

Just locate the

<scriptDisableEditor>true</scriptDisableEditor>

 

In the config\umbracoSettings.config file and change it to false.

/Config/Dashboard.config 5

Just posted this on the forum and I thought I could do a quick post about the umbraco dashboard.config file.

When you log in the the umbraco backend or when you enter a section, the right side of the umbrao backend will be empty

image

You can fill up these ‘dashboards’ with tab pages that contain usercontrols.

How do you do this ? You will have to edit the /config/dashboard.config file.

Default the dashboard.config file looks like this:

<?xml version=”1.0″ encoding=”utf-8″ ?> 
<dashBoard>
<!–
    <section>
    <areas>
        <area>default</area>
        <area>content</area>
    </areas>
    <tab caption=”Last Edits”>
        <control>/usercontrols/dashboard/latestEdits.ascx</control>
    </tab>
    <tab caption=”Latest Items”>
        <control>/usercontrols/dashboard/newestItems.ascx</control>
    </tab>
    <tab caption=”Create blog post”>
        <control>/usercontrols/umbracoBlog/dashboardBlogPostCreate.ascx</control>
    </tab>
</section>
–>
</dashBoard>

 

So to add a usercontrol to th content area we should add this:

<?xml version=”1.0″ encoding=”utf-8″ ?> 
<dashBoard>
 
    <section>
    <areas>
        <area>content</area>
    </areas>
 
    <tab caption=”Last Edits”>
        <control>/usercontrols/mycustomusercontrol.ascx</control>
    </tab>
 
</section>
</dashBoard>