Thursday, 18 August 2011

Introducing a new Umbraco datatype for Multi-lingual websites.

Over the last 6 months we have been building various multi-lingual sites for different clients and for some of the clients they have 1 to 1 relationships between some or all of their pages.

Within Umbraco, you can copy a page ( or whole tree of pages ) and keep a relationship between each of the pages and their new copy, this allows content editors to subscribe to change notifications that Umbraco can create if one of the linked pages is changed.

Unfortunately one thing that is missing in Umbraco is any way to see which pages are related to each other and to have a quick and easy way to jump between the related pages.

We created a datatype that solves these problems and thought we would release it as an open source project ( which we are still maintaining )

Currently you can:

1) See current relationships
2) Add relationships
3) Limit the number of relationships that can be added ( by the data type )
4) See the Country flag ( assuming a culture has been set on each of your top level site nodes for each country site )
5) Link between the documents
6) Change or delete the links

An example where multiple languages are allowed:

An example where only 2 languages exist (1 relationship):


You can download the datatype from the Umbraco project page:
Vizioz Relationships for Umbraco

Please do let us know what you think :)

Umbraco Gold Partner and the last 6 months.

As with a lot of blogs, unfortunately over the last 6 months our blog has been feeling some what neglected, the good news, is this has been due to us going from strength to strength :)

In the last 6 months we have developed 5 more Microsites for Microsoft, we have helped a London agency fix a dire Umbraco implementation for a global drinks brand, built a great site for a famous food product range and most recently we are working with DairyMaster in Ireland building them a new website for their global distribution network and over the next couple of months we will be launching their new global marketing websites in 9 different languages.

As well as working with these great clients, we also helped ResourceiT launch their new website in time for the Microsoft Global Partners conference.

In December, Umbraco HQ launched their Umbraco Gold Partner programme, Vizioz was proud to be one of the first Gold Partners in the UK, showing our clients that we are investing our money in the product we promote, ensuring that Umbraco continues to go from strength to strength.

Monday, 15 November 2010

Creating PDF documents dynamically using Umbraco and XSL-FO part 2

Since my last post I have made a few modifications to the PDF generation, the main one being that the files are now dynamically renamed so that they reflect the name of the case study instead of all being called PDF.PDF which was not a very helpful filename, I just wanted to get something live last week, so decided that something was better than nothing :)

The issue with the filenames comes down to the way that the PDF's are being generated by using an alternative template in Umbraco, this means that all you need to do is add " /pdf " to the end of a case study URL and it will create a PDF version of the case study. The down side is that your browser will merrily download the file and save it as PDF.PDF because that is the name of the last part of the URL.

What you need to do is set the content-disposition header to be equal to the name you would like the file use, Darren Ferguson mentioned this on the Change the name of the PDF forum post.

We have used the same technique for downloading dynamically generated excel files, so I thought it would be useful to create a small macro to set both this header and also to set the caching headers to prevent any caching issues, I think in the past we have experienced all possible issues, including various issues where IE behaves differently to other browsers when you are using SSL and so the below code should work in all situations!

The template for the PDF alternative template is very simple:

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
   <umbraco:Macro Alias="PDFHeaders" runat="server"></umbraco:Macro>
   <umbraco:Macro xsl="FO-CaseStudy.xslt" Alias="PDFXSLFO" runat="server"></umbraco:Macro>
</asp:Content>

The following code snippet is the XSLT macro that simply creates our file name and then passes the file name into the helper function:

<xsl:template match="/">
        <xsl:variable name="fileName">
            <xsl:text>Vizioz_</xsl:text>
            <xsl:value-of select="$currentPage/@nodeName" />
            <xsl:text>_case_study.pdf</xsl:text>
        </xsl:variable>
        <xsl:value-of select="Vizioz.Helper:AddDocumentDownloadHeaders('application/pdf', $fileName)"/>
    </xsl:template>

And the following code is the helper function that clears the current response and adds all the appropriate headers:

public static void AddDocumentDownloadHeaders(string contentType, string fileName)
{
 HttpResponse response = HttpContext.Current.Response;
 HttpRequest request = HttpContext.Current.Request;

 response.Clear();
 response.ClearHeaders();

 if (request.IsSecureConnection & request.Browser.Browser == "IE")
  {
   // Don't use the caching headers if the browser is IE and it's a secure connection
   // see: http://support.microsoft.com/kb/323308
  }
 else
  {
   // force not using the cache
   response.AppendHeader("Cache-Control", "no-cache");
   response.AppendHeader("Cache-Control", "private");
   response.AppendHeader("Cache-Control", "no-store");
   response.AppendHeader("Cache-Control", "must-revalidate");
   response.AppendHeader("Cache-Control", "max-stale=0");
   response.AppendHeader("Cache-Control", "post-check=0");
   response.AppendHeader("Cache-Control", "pre-check=0");
   response.AppendHeader("Pragma", "no-cache");
   response.Cache.SetCacheability(HttpCacheability.NoCache);
   response.Cache.SetNoStore();
   response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
  }

 response.AppendHeader("Expires", DateTime.Now.AddMinutes(-1).ToLongDateString());
 response.AppendHeader("Keep-Alive", "timeout=3, max=993");
 response.AddHeader("content-disposition", "attachment; filename=\"" + fileName + "\"");
 response.ContentType = contentType;
}

I will write another blog soon with some more details about XSL-FO and how to create the PDF's dynamically.

Please do re-tweet if you find this interest :)

Top 5 most popular posts