03-21-2008
Layout issue with Umbraco macro
This is one that maybe could help some other developers that are new to Umbraco, and more specifically to XSLT. On our latest project we had our builder getting to grips with Umbraco and adding the html build to the existing XSLT macros. However, despite the fact that Umbraco does not mess with your markup, we were having layout issues. Paste the html into the template and it’s perfect, but put it into the macro and it screws up the layout. What’s going on? Is Umbraco actually doing something to the markup? Surely not!
After some digging around one of the guys found that empty divs were being converted by the xslt files. The html source
<div class=”clearBoth”></div>
was being output as
<div class=”clearBoth” />
which caused the html to display incorrectly.
This is because the XSLT was treating the HTML as XML and ‘cleaning’ the code before outputting it. The way XSLT outputs the code depends on the xsl:output tag which can be set to XML or HTML:
<xsl:output method=”xml” />
OR
<xsl:output method=”html” />
Setting this to HTML will ensure that you do not experience the same problems that we had. More info can be seen at:
http://www.w3.org/TR/xslt#output
Many thanks to Toby for finding the solution to this one!
David
Posted by dotnetdave in .NET 2.0 Development | No Comments »
12-03-2007
The 24 Days of Umbraco Christmas Bonanza!
I see that Niels is going to be posting some tips ‘n tricks about Umbraco over the next 24 days. The entries for the first and second of December are excellent - if you’re new to Umbraco than check the “Resources and where to find help” blog entry for the best places to start. It’s all online on the Umbraco blog.
Meanwhile here at Equator, we’re getting stuck into our second Umbraco site at the moment. Jarrod, Jamie and Graeme will be doing most of the work this time, but I will be helping out as time allows. So I’m hoping to see some slightly more advanced stuff on the blog over the next three weeks as well.
Dave
Posted by dotnetdave in .NET 2.0 Development, Umbraco | No Comments »
11-28-2007
Bizarre Bug of the week - SYLK file
I’ve just been working on a quick way to allow a client to view their email subscriptions from their site. They request the correct page which reads the database table, creates a csv file, then emails it as an attachment. Fine - worked first time. Just need to add the column names in the first line of the file. The first column, as is often the case, is the primary key called “id”. So, the first two characters in the file become “ID”.
Bug!
When I click on my attachment in my inbox, Excel gives me this message:
Excel has detected that ‘emails.csv’ is a SYLK file, but cannot load it. Either the file has errors or it is not a SYLK file format. Click OK to try to open the file in a different format.
Admittedly not the most serious bug in the world, it does look crap and possibly might worry an end user. Quick Google search to find this explanation: “SYLK: File format is not valid” error message when you open file
The solution? Change the first two characters of the file so that the file does not begin with uppercase “ID” - even lowercase “id” will work. I changed mine to ItemID and I was away.
So play safe with those csv files kids!
Posted by dotnetdave in .NET 2.0 Development | No Comments »
11-21-2007
Christmas lights on already? What a nightmare
If this wasn’t a work-related blog I’d be swearing my head off. Went into Glasgow city centre on Sunday (yeah, I know, I won’t be making that mistake again in a hurry) to get a couple of things and what? It’s suddenly bloody Christmas? Christmas songs in all the shops, Christmas decorations everywhere, people going totally apesh*t with credit cards and worrying about getting that perfect present for some git in their family - and it was only November 18th! Not that I’m advocating that kind of consumerist feeding frenzy EVER, but you know second week in December I could maybe let you off with it. And the huge fuss, a ticketed event no less, for the turning on of the lights in George Square. Utter madness. A town full of idiots with lots more money (or credit) than sense.
Oh my god everybody please stop this madness. No wonder the UK has such a massive consumer debt (what is it, 1.3 trillion pounds at the moment?). No wonder everyone is depressed. I certainly was. It took me over an hour of Wife Swap on the telly to calm down (but don’t get me started on reality tv). And a couple of pints of course.
Bah humbug indeed.
Posted by dotnetdave in Glasgow | No Comments »
11-19-2007
Is that you pal?
Full transcript of a conversation overheard at the till at the BP garage in Ibrox last Sunday morning:
Attendant: “Is that you pal?”
Customer: “Aye”
Absolutely classic Glasgow.
(Translation:
Attendant: “Would you like anything else with that, sir?”
Customer: “No thank you, my good man. That will be all.”)
Posted by dotnetdave in Glasgow | 1 Comment »
11-08-2007
Thoughts on Umbraco after getting my first site live
I know there is plenty of activity in the area of ‘my favourite CMS’ in the blogosphere, but I just thought I’d add my tuppence worth after completing my first Umbraco site. It’s a pretty pure site with only a single .NET user control, everything else being 100% Umbraco. Here are my thoughts on the experience:
- XSLT is obviously a huge part of Umbraco as it’s used to create your macros which are more or less the intelligence of your running site. I had no experience in this area before beginning and yes it was definitely frustrating. However, three weeks later I’m much more confident with it and can achieve the majority of the tasks I need to with ease. The patterns you use tend to be similar to others you’ve already written and it soon gets familiar.
- The output from Umbraco was perfect, no layout issues or strange characters being outputted, only the content styled and laid out as specified in the template.
- The ability for the programmer to work simultaneously with the html/css builder was a great advantage. None of this handing of html to the programmer to wrap around his code, the builder can get straight in and input the styles, etc, directly. Also, it’s feasible that if your builder is up for it they can get to grips themselves with the XSLT, document types, templates, etc, and the programmer can concentrate on the more difficult (and interesting!) programming tasks. This saved us loads of time, especially in the final phase of the project where we were finessing the site for the client.
- It sometimes feels with Umbraco that to do very basic tasks (which you might expect would involve a drag-and-drop operation or a button to click) involves semi-complex (and often complex) XLST. For example to get an image to appear on the page! At first this was a source of frustration but once you’re used to working with the XML which represents your site you take it in your stride.
- I haven’t had to use the Umbraco dlls within my .NET user controls as yet, that will have to wait for the next project. However, adding my .NET user controls into Umbraco was simplicity itself.
So overall it’s been an interesting learning experience, frustrating at times but ultimately fulfilling. The site is live and on time, the client is happy and in control of their site, and most importantly my manager is also happy! I’ll definitely be using Umbraco again in the future and I know that here at Equator we are looking at using it for similar projects in the near future.
Dave
Posted by dotnetdave in .NET 2.0 Development, Umbraco | 6 Comments »
10-23-2007
Excel search and replace error formula is too long
I wrote a post a few weeks back about a .NET tool which allows you to search and replace text type fields in a SQL database - a non-trivial problem.
This morning I needed to perform something similar using Excel. Data from the client included tags like [HTML-BR] in the description fields, many of which were quite long. On trying to do a find and replace operation in Excel, I got the error message: Formula is too long.
With over 550 rows in my spreadsheet this had suddenly turned into a serious problem. So what I did was this. Using SQL Server I imported all of the data from my spreadsheet into a table in my database. I re-read my old post http://equatorlive.com/blogs/dotnetdave/tech/sql-search-and-replace-on-text-type-columns/, edited the app.config file for the application and let it rip. When I’d finished replacing the various rogue codes from the data in the table, I then exported the data back to my Excel spreadsheet.
A bit of a longwinded solution for such a simple problem but there you go - I was sorted in 20 minutes. Definitely a handy tool to have around!
Hope that helps,
Dave
Posted by dotnetdave in .NET 2.0 Development | 2 Comments »
10-22-2007
Umbraco content not updating correctly
On Friday last I was having the following problem with my first attempt at an Umbraco-driven website. I wanted to add a new boolean property to a set of content nodes (i.e. type true/false in Umbraco), and use this property to change the behaviour in an XSLT file according to the value of the property. In testing my XSLT, the new property never had any value. I tried everything, making it a text field, copying existing attributes exactly, and still no joy. Pre-existing properties were displayed fine, but not the new one. I gave up and went home for the weekend.
This morning I added a brand new content node - and no sign of it on my site. Now I started getting suspicious and did a little digging. I found this post here on the forum which was very helpful:
http://forum.umbraco.org/xslt/content-not-updating
In summary, to solve my problem I followed these steps:
1. Create a new Application Pool in IIS for the site, which has all of the default settings on the machine and runs under the NETWORK_USER user.
2. Ensure the NETWORK_USER has modify rights on the \data folder in the Umbraco installation directory.
3. Do a “Republish All Content” by right-clicking on the Content root node in the Umbraco dashboard.
Et viola!
This is yet another example to back up my argument that when you get frustrated with a problem instead of tearing your hair out into the wee hours it’s best to walk away from it - chances are you’ll sort it first thing in the morning. This doesn’t work for everyone but I find I make more mistakes the later it gets, and it’s actually counterproductive to stick around. Clearing the head and sleeping on it works wonders!
Hope that helps,
Dave
Posted by dotnetdave in .NET 2.0 Development, Umbraco | 2 Comments »
10-18-2007
Umbraco Access to the path to data umbraco.config is denied.
This morning I’ve been working on moving my local Umbraco installation onto one of our servers. I’m doing this to get my Umbraco work included in the nightly backups, and also to allow access to the sites I’m working on to content managers, css builders and, eventually, clients.
I copied my Umbraco database to the new database server and that wasn’t a problem using the new SQL Server Database Publishing Wizard (which can be found here: http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en - thanks to Kevin for the tip!). Then I copied my web directory on to the server as well. Initial attempts at a quick browse of the sites gave me this beauty of an error:
Access to the path ‘E:\WWW\MyUmbracoSite\data\umbraco.config’ is denied.
Exception Details: System.UnauthorizedAccessException: Access to the path ‘E:\WWW\MyUmbracoSite\data\umbraco.config’ is denied.
I checked the file and ensured that the ASPNET user had full access - check. Still no joy. I to-ed and fro-ed for a while and even had to reset IIS on the server a number of times as I was getting Server Unavailable messages. It turns out that the solution was simple: I needed to update my database connection strings in the web.config and ensure that the user specified exists in my new database and has access to the database required. Once this was achieved, I was good to go!
Now I know I’m new to Umbraco but this error message and my ensuing problems with IIS needing to be restarted seems like a frustrating wild goose chase when the actual problem was in my web.config the whole time! Hopefully this post might help some poor soul who finds themselves in a similar situation.
Hope that helps,
Dave
Posted by dotnetdave in .NET 2.0 Development, Umbraco | No Comments »
10-17-2007
Using .Net2 Web User Controls with Umbraco
Umbraco has so far proved itself to be an excellent content management system, very powerful and extensible. But what if I want to do some external jiggery-pokery like saving contact details to an external database? Well, it’s simple. Umbraco allows you to take your .NET user controls and wrap them in a macro, which is then treated like any other macro is. You are really just disguising your .NET control as a macro. The control itself can do whatever you like, it can accept parameters from Umbraco, do anything under the sun that you can think of and even display a friendly little message to the user afterwards if you like.
If you are developing with Visual Studio 2005, however, there is a little catch. What you want to do is to create a web application project which then compiles to a dll which can be dropped into your Umbraco directory. However, with Visual Studio 2005 the default installation does not allow you to create this type of project, for some reason it went out with VS 2003. The solution is to download the Microsoft Visual Studio 2005 Team Suite Service Pack 1, which you can find here: http://msdn2.microsoft.com/en-gb/asp.net/Aa336618.aspx This page also includes some more information on why you would want to install the update.
Anyways, once that’s done it’s simple. You can create a new web application project called something like “MyUmbracoProjectControls”. In this project you create all of your user controls for your site. You can build and test them here as normal. You can even do some really clever stuff like adding postbuild events to your project which copy the required files into your Umbraco directory every time you build your project - see this post on the Umbraco forum for more details: http://forum.umbraco.org/yaf_postst1083_Installation-troubles.aspx This excellent post by Daniel Lindstrom also explains how you can debug your controls using Visual Studio 2005 while browsing your Umbraco website.
Hope that helps,
Dave
Posted by dotnetdave in .NET 2.0 Development, Umbraco | No Comments »