Nibble

Archive for October, 2008

Preview of an upcoming package: Link Checker for umbraco 2

The link checker is a tool designed to identify broken links within your umbraco website. It will check all links (internal, from the same host, and external, outgoing link to different domains) found in the properties of your published content pages.

It has tree stages:

  • Start, options to search only external / internal links, search for all url’s (not only the ones in <a href=”">) and option to set the start node of the search.
  • Running, nice little progress status (the crawler runs async so it’s possible to do another action and check back later)
  • Report, once the crawler is done it will display a report of found broken links

Check out the demo:

brokenlinks

This will be my first ‘commercial’ package, stay tuned for more info.

New Package - Related Links 41

A feature you often see on sites is a list of related links, sometimes all external, sometimes mixed with internal links.

relatedLinks1

relatedLinks3

By default umbrao doesn’t have a dedicated related links datatype, you could use the richtexteditor to manage an unordered list, or maybe even have the links as child documents. But I found a custom ‘related links’ datatype would be a better way in doing this.

So here it is ….

After installing and adding the new datatype to a documenttype, it will render like this:

relatedlinks4

 

First a listbox with the option to move an item up and down and to delete an item (first select the item and then hit the button).

Next is the link title with an new window checkbox next to it (checked by default)

Underneath that you can view the different url types.

  • External Url
  • Internal Url (node number)
  • Internal Url (content picker)

External url is basicly for every link that isn’t a link to a content node. Just type in the url and hit add.

Internal Url (node number) you can use in case you know the node number of the content page you want to link to. Fill in node number and hit add.

Internal Url (content picker)

Fill 1 one of those 3 and hit the corresponding add button to add the link to the list.

After hitting the save button the links will be saved as xml.

<links>
<link type=”external” title=”google” link=”http://google.com” newwindow=”1″ />
</links>

To display the links on your template you’ll create a new xslt (with macro).

Example of an xslt that will render the related links (alias of the related links property in this example is ‘link’):

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE xsl:Stylesheet [ &lt;!ENTITY nbsp “&#x00A0;”> ]>
<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:relatedLinks.library=”urn:relatedLinks.library”
    exclude-result-prefixes=”msxml umbraco.library relatedLinks.library”>
 
 
<xsl:output method=”xml” omit-xml-declaration=”yes”/>
 
<xsl:param name=”currentPage”/>
 
<xsl:template match=”/”>
<ul>
<xsl:for-each select=”relatedLinks.library:getRelatedLinks($currentPage/data [@alias = ‘link’])/links/link”>
<li>
<xsl:value-of select=”./@newwindow”/>
<a href=”{./@link}”>
<xsl:if test=”./@newwindow = ‘1′”>
<xsl:attribute name=”target”>_blank</xsl:attribute>
</xsl:if>
<xsl:choose>
  <xsl:when test=”./@type = ‘external’”>
    <xsl:attribute name=”href”><xsl:value-of select=”./@link”/></xsl:attribute>
  </xsl:when>
  <xsl:otherwise>
    <xsl:attribute name=”href”><xsl:value-of select=”umbraco.library:NiceUrl(./@link)”/></xsl:attribute>
  </xsl:otherwise>
</xsl:choose>
<xsl:value-of select=”./@title”/>
</a>
</li>
 
 
</xsl:for-each>
</ul>
 
</xsl:template>
 
</xsl:stylesheet>

Xslt as text: download

The package was made for v3, but it should also work on v4 (if the db is sql server).

Related links package: download

Thanks to Dieter De Paepe (my summer intern), who did a great job putting this idea into practise.