Before we start writing code I’ll explain the business case we are trying to resolve.
The ‘case’:
The business user want to personalize the website based on the website the visitor comes from (the http referrer). For now he is only interested in Facebook and Twitter.
If the visitor visits our site from Facebook the Facebook Like button of our own Facebook page must be visible on the homepage.
If the visitor visits our site from Twitter our Twitter Tweet stream must be visible on the homepage.
Oke, Now start building it!
Create templates
Create a template called Sidebar Text, this template has two field; a Sidebar Title (Single-Line Text field) and a Sidebar Text (Rich Text field).
Create a template called Standaard Text, this template one field called Text (Multi-line Text).
Set up the content tree
Create a folder called Sidebars and add two Sidebar Text items with the following values:
- Item Name: Default Message
- Sidebar Title: Default Message.
- Sidebar Text: This is the default message.
- Item Name: Twitter
- Sidebar Title: Follow us
- Sidebar Text:
Copy Widget HTML generated from: http://twitter.com/about/resources/widgets/widget_profile
- Item Name: Facebook
- Sidebar Title: Like us
- Sidebar Text:
Copy Widget HTMl generated from:
http://developers.facebook.com/docs/reference/plugins/like-box/
Create a folder called Http Referrers and add the following items:
- Item name: Twitter
- Text: twitter.com
- Item name: Facebook
- Text: facebook.com
Create presentation component
Create the Sidebar Text rendering for displaying the Sidebar Title and Sidebar Text.
Open development center and click Create a New XSLT rendering and name the rendering Sidebar Text. Add the following code to the rendering template:
Continue reading “Sitecore Rules Engine: How to create a custom condition”