sloppycode.net
Umbraco hacks for developers
A set of tips and tricks for developers using Umbraco


Sitemap XSLT
The XSL below is the source used for Sitemap on sloppycode.net. It's taken from the Umbraco book, and modified to display the Dublin Core description alongside each page's url.



Changing the content type of a document
I've had to do this quite often on sloppycode.net when I realised I've created something as a Textpage (a built in document type) but then need some code highlighting which comes from a different content type.

I haven't got round to making a tool to do it, but it's simple to do when access to SQL Enterprise Manager/Management Studio.

First of all, backup the content of the document you are going to change. This is important, as changing the content type wipes the content. I don't know why, the developers will know the reason for that. But the bodyText and the properties dissapear. Changing the contentType is straight forward, simply run

in SQL Server Management studio. You can get a list of contentTypes from the contentType table. nodeId holds the ID (rather than the pk column).

Once you have done this, publish your document. It will probably show a null reference exception when you click on the node in the editor. This will go once it has been published.

Moving multiple documents
If you need to move a lot of documents at once to a new parent, it's painful doing it inside the editor. A SQL Script for doing this is below, just change the @oldParentId and @ParentId accordingly. Make sure you backup your database first.

Performance issues with Umbraco
Since installing Umbraco and running sloppycode.net on it since December 2006 I've noticed a few ways of making it go faster. Most of them are out of the box with Umbraco, like using the XML cache however there's a few others worth a mention:

Truncate your umbracoLog table regularly
The table contains all exceptions and warnings plus a host of other information from the Umbraco system. Most of this you don't need and can clog up the database. The table can grow very large quickly, particularly if you're creating the website for the first time and testing. This image shows an example

 umbracotables.gif

Before this the site was 500,000 records strong before I noticed. The backups become large too. So simply run truncate on it:

There's not point saving the deletes to the transcation log with DELETE FROM, as the data is never used by Umbraco except for your information.

Make sure tracing and debug is turned off
Find the following lines in your web.config file and make sure the attributes are set to false, it makes a noticeable difference:

GZip your HTML output
I've written a small HttpModule based on some code by Bart De Smet that's very simple to install. It GZIP's your HTML output, reducing the bandwidth your site uses and page load time. It's aimed at people using shared hosting or pre-IIS 5 servers.

Umbraco source
This is now available thanks to the Umbraco team as a zipped file on Codeplex.com:

Download

Changing templates on multiple documents
Like moving lots of documents at once, this is also a pain in the editor. The code below (for version 3.03) does this for you. You'll need to turn it into a webservice and make a calling application to use it.

Database schema
This shows the schema of the Umbraco database, imported into Visio and organised so the tables are grouped together.

Download the original Visio file

umbraco-schema

Data export

This tool came from having troubles backing up an Umbraco database on gate.com - who didn't allow user backups of SQL databases or remote SSIS packages. The host has now been switched but for users of similar hosts like godaddy.com the tool is useful. Find it at:

http://www.codeplex.com/UmbracoExportTool

Links

These links are included to supplement the ones on the Umbraco.org site.

Version 2 documentation PDF
http://umbraco.org/media/4d051ed3-63c2-42d6-a6c1-e93a14fc24a8-UmbracoDoc.pdf

Old documentation (some isn't on the new site yet)
http://old.umbraco.org/frontpage/documentation.aspx

Wikibooks
http://en.wikibooks.org/wiki/Umbraco

Official utilities:package
http://www.umbraco.org/frontpage/download/extensions/umbracoutilities.aspx

Large amounts of packages
http://rtk-cv.dk/1050.aspx

Lots of information and links
http://ismail.umbraco.net/ is a great place to browse for information, the links section is also very handy.



› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search
› Sitemap





Buy on Amazon



Buy on Amazon



Buy on Amazon



Buy on Amazon