17 December 2007

Get collection of Sitecore Weblogs in Netvibes

I have been using Netvibes as my starting page. I like that more than iGoogle. Here is my collection of Sitecore RSS feeds. Collection contains about +25 blogs, Sitecore corporate news and Sitecore Developer Network articles and forum posts in RSS. There is also Google Custom Search for Sitecore on Sitecore related blogs.



If you have a Sitecore Blog or another useful resource that is not listed here. Please let me know



Click here to preview:Add to Netvibes

24 August 2007

Workflow

Some sample code how to manage workflow on Sitecore.

27 January 2007

Sitecore Developer Search

I was playing around with Google's Co-op and Netvibes API (cool services both of them!) and I drafted out simple a little Netvibes module that searches through few Sitecore Sites and Blogs.
If you have a Netvibes account give a try and if you want some more sites into the index drop me a mail at jp at addition.dk.


Netvibes Sitecore Search Module

Add to Netvibes



And... if you want to Subscribe to Sitecore Experience on Netvibes click button below:


Subscribe to The Sitecore Experience on Netvibes

Add to Netvibes

17 January 2007

Read image attributes from media library images

This is nice when you need to know what is the size of the image.
sc:fld('height',sc:item(concat('/sitecore/media library', sc:fld('banner',.,'mediapath')),.))
Returns height of the image in "banner" field.

14 September 2006

using Sitecore.Kernel.Webutils

Webutils functions can be used as helper functions as well. In order to get the url of the server, we can use it as follows:

install it in web.config:

<xslExtensions>
...
<extension mode="on" type="Sitecore.Web.WebUtil, Sitecore.Kernel" namespace="http://www.sitecore.net/webutil" singleInstance="true" />
</xslExtensions>


declare it in your xslt:

xmlns:webutil="http://www.sitecore.net/webutil"


then use it (example from a "print page" footer):

<xsl:text>Artiklens placering: </xsl:text><xsl:value-of select="webutil:GetServerUrl()" /><xsl:value-of select="sc:path(.)" />

util:GetString

It might be not obvious but is common practice to use util:GetString(string, default).

A xsl:choose used to display the title of an item can be replaced as follows:


<xsl:choose>
<xsl:when test="sc:fld('menutitle',.)">
<xsl:value-of select="sc:fld('menutitle',.)">
</xsl:when>
<xsl:when test="sc:fld('title',.)">
<xsl:value-of select="sc:fld('title',.)">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./@name">
</xsl:otherwise>
</xsl:choose>


simpler call:


<xsl:value-of select="util:GetString(util:GetString(sc:fld('title',.), sc:fld('menutitle',.)),@name)"/>

22 May 2006

Sitecore performance - xslt NONO !

Fyi -> speed problems could be caused by one single line in xslt ( impressive that you can kill a dual core P4 64bit 4Ghz with 8 GB mem in one single code line ).

Never compare nodeset´s unless you really have to .. what you typically need is to figure out if current node is thye same as home node … do NOT do like this :
xsl:if test=”$home=$sc_current” …. < -- no no no .. verboten !!!! STOP !

The line above will loop all nodes under $home and compare every node with every node in $sc_currentitem.

Ofcourse what you DO want to do is :
xsl:if test=”$home/@id=$sc_current/@id

If you experience speed problems, this could be why !

14 February 2006

Two useful tips for dtSearch customization in Sitecore

dtSearch and Mixing Text Query
In dtSearch when I search with multiple words its always exact match search. For example:
If I write query "Product Foobar". When in my page there is text "Foobar Product".

Solution:
But dtSearch has the following search options defined:

public enum Options
{
AllWords = 2,
AnyWords = 4,
CaseSensitive = 8,
ExactPhrase = 1,
Logic = 0x20,
Ranked = 0x40,
WildCards = 0x10
}

To use these options, you should create the custom xslt extension which will return Sitecore.Modules.Search.dtSearch.Search(searchString, Sitecore.Modules.Search.Options.AllWords)

Multiple indexes

Sometimes you might have multiple sites on same installation of the Sitecore and you want search index also be separated to each sites.
For example if you Sitecore content tree looks like:
Intranet
WebSite
ExtranetSite

Then create normally separate indexes in dtSearch indexer on the server and add the following lines in the web.config file.






Intranet" value="Intranet" />

WebSite" value="/index/" />
WebSite" valueWebSite/>

ExtranetSite" value="/index/" />
ExtranetSite" value="ExtranetSite" />

You of course need XSL helper or custom function below to switch between sites

private string GetSearchResultIndex(string dist)
{
string searchText = txbSearch.Text;

// Instantiate the Search Engine
ISearch engine = Sitecore.Modules.Search.Factory.CreateSearchEngine();

// Get the dtSearch engine implementation
dtSearch your_dtSearch = engine as dtSearch;

// Set index
string pathIndex = Server.MapPath(pathIndexDtSearch(dist) + nameIndexDtSearch(dist) + "\\");
your_dtSearch.Index = pathIndex;

// Execure search
your_dtSearch.SearchTextOptions(searchText, Options.AllWords);

// Get search resalts as XML
System.Xml.XmlDocument searchResult = your_dtSearch.SearchResults;

// Format result
string result = string.Empty;
System.Xml.XmlNodeList list = searchResult.SelectNodes("/sitecore/result/item");
foreach(System.Xml.XmlNode node in list)
{
string url = node.SelectSingleNode("url").InnerText;
result += "" + url + "
";

}
return result;
}