My Sitecore 6 twitter module

For a couple of weeks ago I had fun making a twitter module for Sitecore 6.   The main goal of this module was to show of some of my skills as a Sitecore developer, and i want to share this with you (c:. Her are some of the highlights.

  1. Sitecore scheduled twitter updater task, that manages import of twits from a given Twitter user
  2. All twits are saved as Sitecore Items.
  3. All twits are displayed with a XSLT rendering.
  4. Download the package and the source files(at the end of the article)

Short description of the Sitecore Setup.

The Sitecore Scheduled task is setup to call the twitter manager webform witch gets all new twits from a twitter account which is defined by name in Sitecore. Here you can see it running on my machine
The webform called by the Sitecore scheduled task stores all the new twits as Items in the master database and publishes them to web database. These items are purely meant as data items,  so they have no renderings or layout attached to their template.  All the twit items are placed under the “global” folder item so they can be separated from all the other nondata items like my Twitter page item(described below).

An example off twits items generated by my twitter manager. Every Item is named so it will allays have a unique name.

Twitter manager webform called by the Sitecore, gets it’s twitter username from the Twitter page item, which in my example can be found under the Home root item.

Here you can see the twitter item based on the TwitterManagerPage template. Items based on this template are meant to display all twits from a given user in this case me (c:

Items based on the TwitterManagerPage template has its own icon and device setup.  So they can be used to show a list of twits items stored within the sitecore in the front-end.

Here you can see the setup of device for the TwitterManagerPage template.

To display a list of twits, I’ve made a simple layout with a placeholder, that in my case  is used to display a rendering, which renders all the twit items in the global folder as a sorted list.

her you can see the layout and rendering associated with twitter manager.

I like to keep my things neat so i’ve added a TwitterManager folder to layouts rendering and templates folders (c:
If you want to try this twitter module you can download the package that i have made here.  Remember to read the readme file which explaines in further detail the content of the pakadge and the install procidure.

When the twitter module is installed and up  runing on your Sitecore solution, you should be able to se a list with twitter entries like this one (c:


TwitterManager Package[33kb],   TwitterManager source code [3mb]

if you have any questions to the source code or the description above, fill free and ask (c:

XSLT bug, xslt removes html tags by it self

And this is a fact,.. I often use  HTML  when i make my renderings for Sitecore.  If yore not care-full,.. you can end up with a site which is not W3C compliant or even worse if it messes up your design,..

So her’s the problem,. if you type something like this in your XSLT
<div class=”separator”></div>

XSLT will only render the start tag, like so
<div class=”separator” >

the only solution for this is to place some kind of content inside your empty tag
like a white space,.. But be careful to put &nbsp; inside your XSLT it will result in error. Use &#160 ; in stead (c:

happy coding

Another solution for this was proposed by Richard Willis, thanx body
change your <xsl:output method=”xml“>  to <xsl:output method=”html“>
that will instruct the render to format your output like HTML, like we want to..

How to programaticly update item fields in Sitecore

It is quaite streat forword, there is one thing thou that you should take notice of..
if you just get tour item from master database you can get up getting the wrong version of the item in a wrong language ,.. so this eksample will compile but jeald falsy results.

string guid ="{............}"
Database database = Factory.GetDatabase("master");
Item item = database.GetItem(guid);
 using(new EditContext(item))
     item.Fields["fieldname"].Value = "new value";

So to get the right version from the right language, you should do something like this.

Database database = Factory.GetDatabase("master");

Item item = database.GetItem(guid,Sitecore.Globalization.Language.Parse("da"),Sitecore.Data.Version.Latest);

 using(new EditContext(item))
      item.Fields["fieldname"].Value = "new value";

Notice that i am using Sitecore.Globalization.Language.Parse(“da”) to get the language i wanted and Sitecore.Data.Version.Latest to get  the newserst version of my item. (c:

an that is all she wrote (c;

Performance tricks when developing Sitecore solutions

When developing you want your solution to be as streamlined as possible, you don’t want to save logs and media files. To cut down in the size of the Sitecore development environment this is what you can do.
Open your web confic and look for this bit:

      <!-- Agent to cleanup work files -->
      <agent type="Sitecore.Tasks.CleanupAgent" method="Run" interval="06:00:00">
        <!-- Specifies files to be cleaned up.
             If rolling="true", [minCount] and [maxCount] will be ignored.
             [minAge] and [maxAge] must be specified as [days.]hh:mm:ss. The default value
             of [minAge] is 30 minutes.
             [strategy]: number of files within hour, day, week, month, year
             [recursive=true|false]: descend folders?
        <files hint="raw:AddCommand">
          <remove folder="$(dataFolder)/logs" pattern="log.*.txt" maxCount="20" minAge="7.00:00:00" />
          <remove folder="$(dataFolder)/viewstate" pattern="*.txt" maxAge="2.00:00:00" recursive="true" />
          <remove folder="/App_Data/MediaCache" pattern="*.*" maxAge="90.00:00:00" recursive="true" />

Change all maxAge atribute to 01:00:00, this wil remove all older files when this agent runs. No more gigabytes of log files to bloat up your solution ,.. sweat (c;

How to get image src from an Image field

I was wondering how to get at src atribute of an Image field in Sitecore,.. her’s an exsample of what data you can find in the Image field..

<image showineditor=”1″ mediaid=”{6WB581DF-395F-400B-A8F2-98690D18AD10}” mediapath=”/Images/yourImage” src=”~/media/Images/yourImage.ashx” />

so if you do a xsl value-of you’ll get this in stead of the image src,.. and that is just not what i wanted ,.. so to solve this you can do folowing

<xsl:value-of select=”sc:fld(‘imageFieldName’, . , ‘src’ )”/>

and thats it (c:

Web.confiq tips of the day (c:

if you want to define a special or multiple sites using sitecore ,.. this is the way to do it.

Open your Web.cinfig and look for “sites” attribute.  Here you can add your site definitions

It could look something like this ,..


<site name=”Mywebsite”  hostName=””
















Creating chunks in Sitecore 6

If you are thinking that this is the same as in Sitecore 53.. you are mistaken they have moved the ribbons and chunks to another place ,.. if you are looking in where they should be sitecore/sytem/ribbons/chunks, you’ll be pleasantly disappointed (c: Well do not displear you can find them at /sitecore/content/Applications/Content Editor/Ribbons/Chunks

her how Chris does it
Part 1:
Part 2: