by Aboo Bolaky
11. February 2009 07:53
In Sitecore 6.0, a new Link Manager class has been added. In the web.config, a few properties affect the functionality of the Link Manager. I've already posted on the EncodeNames property (fyi, default value : false).
The AddAspxExtension Property
On the surface, I can clearly relate to the functionality of this property. If this is set to false, we are instructing Sitecore to render links (i.e via <sc:link>) without any extensions. This is (alledgedly) GREAT NEWS for SEO experts. If you leverage this functionality with some Url Rewriting (either via Helicon Isapi Rewrite Lite (free) or UrlRewriter.Net ), you must be thinking that you will have a Sitecore front-end website without any extensions.
The Glitch...
If you spent most of your time in implementing regular expressions to rewrite (under the hood) those extensionless links to .aspx and feed them back to Sitecore, Well...I'm afraid you have wasted your precious time (no matter how cool your regex expressions are!!). The moment you try to access the Content Editor in the CMS, you simply receive some weird error messages. Sometimes, it's the dreaded YSOD (Object Reference not set to an instance of an object) or occasionally a 404 page welcomes you. With the AddAspxExtension property set to false, you might end up with a fancy looking frontend and NO backend support at all. Not very usefull... Did a bit of research on SDN5, turns out that the symptoms are correct
This has led me to believe that, in the midst of tackling problems that vary in programming complexity and requirements , always take a step back and test both the front end and back end when dealing with "unchanted territories".
And then...
The search to build an SEO friendly website in Sitecore continues.. Surely, I'll get the better of this (it's just a matter of time...why not build up the suspense?) and will let you know how I did it !!!!
Back to Sitecore now....
by Aboo Bolaky
2. December 2008 11:03
This post is merely a follow up on my previous post : SEO Friendly Urls in Sitecore -Remove spaces in Url .
Even if you use the encodeNameReplacements settings in your web.config, this may well not be enough to get you going with clean urls. Although it will allow you to access an item by replacing the spaces with a dash (.i.e. if you chose to replace a space with a dash in the encodeNameReplacements element) in the url, the links that are rendered on the page (either by doing sc:link in xslt or the usual .net code) will still contain "%20" characters.
Now, this is the bit where I "kind of" messed up. In Sitecore V6 , we have the concept of LinkManager in the web.config. By default, the EncodeNames property is set to true. This is correct and you SHOUD NOT CHANGE IT. If the EncodeNames property is set to false, you will end up having "%20" characters in your hyperlinks.
The big question for me is when and why did I change the EncodeNames to false? I don't know.. Maybe I thought, at some point in time, that toggling the key to a value of false would solve some other problem that I was experiencing?
Anyway, had I not changed EncodeNames to false , I would have never the known the actual meaning and implications of EncodeNames. We learn from our mistakes...
While we're here, you can remove the language code in the urls (http://hostname/en/node1/child.aspx) by changing the key languageEmbedding to "never". In that case, you will end with a url that looks like http://hostname/node1/child.aspx.
Back to Sitecore now..
by aboo bolaky
30. November 2008 06:36
For those Sitecore lovers..
When you code against Sitecore, whether against renderings or sublayouts, I'd suggest you have a look at the very useful methods defined in Sitecore.Web.WebUtil Class. Those methods will help save you some time and prevent you from re-inventing the wheel. Some methods worth mentioning are :-
string AddQueryString(string url, params string[] parameters)
string AddQueryString(string url, bool xhtml, params string[] parameters)
string ExecuteWebPage(string url)
string ExtractFilePath(string url)
string ExtractUrlParm(string name, string url)
Placeholder FindPlaceholder(string key, Control root)
HtmlAnchor GetAnchor(Item itm, string linkField)
Control GetErrorControl(string error, string details)
Control GetFormControl(Page page)
string GetFormValue(string fieldName)
string GetFullUrl(string url, string serverUrl)
string GetHostIPAddress()
string GetHostName()
string GetQueryString()
string GetQueryStringOrCookie(string key, string defaultValue)
void RedirectToErrorPage(string text)
string RemoveQueryString(string url)
void ReloadPage()
string ReplaceUrlParameter(string url, string replace, string withtext, bool append)
Alternatively, you can have a peek at all the methods in the screen grab below [Click on the image for a better view..]
by aboo bolaky
29. November 2008 09:50
Aliases in Sitecore
Sitecore has the concept of "Aliases", whereby each item can accessed using a specific name (rather than the default path). Aliases are turned on by default. To turn them off, you can flip the web.config settings name AliasesActive to false (But who would want to do that????
)
Space Characters in Sitecore
When you create an item in Sitecore, you free to choose the naming of your item (provided it succesfully validates against some key rules .e.g Item name cannot contain :,?.. otherwise, you will end up with a "Item xxx is not a valid name"). Most of the time, you will want to put spaces in the item name. Let's take an example:
If an item (at the root level) has an item name of "John Doe", the url of the actual page should theoretically be http://hostname/John%20Doe .
Of course, you can get rid of this spacing issue by specifying an Alias of John-Doe on the item itself. But imaging you having hundreds of items with spaces !!!..
The encodeNameReplacements element in the Web.config
This encodeNameReplacements settings allow you to globally replace any unwanted character in your url to a character of your choice. So, rather than creating an alias for each item (without spaces), we can add the following new setting.
<encodeNameReplacements>
<replace mode="on" find="&" replaceWith=",-a-,"/>
<replace mode="on" find="?" replaceWith=",-q-,"/>
.....
<replace mode="on" find=" " replaceWith="-" />
</encodeNameReplacements>
Job Done ! 
by Aboo Bolaky
4. November 2008 08:44
Over the past few weeks, I've had the opportunity to use Sitecore to build a website. Whilst i still consider myself to be a novice in Sitecore, I'm afraid I won't be able (at least for the time being!!!) to shed more light on this powerful Content Management System.
However, he're is a video that will help you "understand" what Sitecore is REALLY about. Great marketing stuff!!!
PS: Sitecore isn't just a CMS...
Anyways, I'll keep you all posted about my learning journey with Sitecore. So far, it's been GREAT!!