Sitecore CMS and everything related RSS 2.0
 Wednesday, January 14, 2009

Sitecore has a number of ways to reference an item. Most common are ID and path, and most methods will accept either System.String or Sitecore.Data.ID parameter.

Item item = Context.Database.GetItem("/sitecore/content/somepath");
Item item = Context.Database.GetITem(ID.Parse("{11111111-1111-1111-1111111111111111"});

Our internal convention is that the ID can be used instead of path. You can supply the id as a string to methods that expect a path:

Item item = Context.Database.GetItem("{11111111-1111-1111-1111111111111111"}");

However you have to remember that neither path nor ID identify a piece of content in a unique way. Because Sitecore supports versions and multiple languages, a single item can have 3 versions in English and 2 in Danish. If you only use path or ID when retrieving items, you will get the latest version in the current (Sitecore.Context.Language) language.

Sometimes you need to be specific, so the GetItem() methods have overloads allowing to specify language and version:

Item item = Context.Database.GetItem("/some/path", Language.Parse("en"), Version.Parse(2));

Items can also come from different databases. Notice that I have been using the context database in the above examples, which depends on the current site and Sitecore configuration.

To identify an item, or rather a version, in a unique way, Sitecore has an ItemUri class. ItemUri is an ID or path, language, version and database name bundled together, as well as a number of convenience methods. This is how it looks like:

// get the item URI
ItemUri uri = Context.Item.Uri;

// string representation
string uriString = uri.ToString() -> "sitecore://master/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}?lang=en&ver=1"

// parsing a string
uri = ItemUri.Parse(uriString);

// get an item by URI. Static Database.GetItem method can be used because URI includes database name.
Item item = Database.GetItem(uri);

There is a reason why paths or IDs remain most common ways to reference an item - usually it is a good thing that code adapts to current context and configuration. For some less typical Sitecore tasks, URIs can be handy.

Wednesday, January 14, 2009 1:07:50 PM (FLE Standard Time, UTC+02:00)  #    Comments [2]
Sitecore
 Thursday, December 18, 2008

Presentation Usage ReporterA new project by Alenka Caserman: Presentation Usage Reporter integrates in Content Editor and shows where your presenation components, such as renderings and sublayouts, are used.

Thursday, December 18, 2008 9:27:30 AM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore | Open Source
 Tuesday, December 09, 2008

Changelog:

  1. Fixed: Installation wizard didn’t install files marked to skip if exists.

  2. Fixed: XSL renderings might fail occasionally under high server load.

  3. Fixed: Creator-Owner role might be ignored when resolving access rights.

Download.

Tuesday, December 09, 2008 6:13:12 PM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore | Crestone
 Saturday, November 15, 2008

This post continues the series about the new field editing infrastructure introduced in Sitecore 6: I’ve talked about the renderField pipeline, and how you should be using renderField from .NET. Today is the example day.

Let’s start with links. You can put sc:Link control directly on the aspx page:

<sc:Link Field="Link" runat="server" />

This is a minimum set of parameters – you need to specify the field name at least. The control will use context item to get the field value. If you need any other item, you can use Datasource property in a declarative manner:

<sc:Link Field="Link" DataSource="/sitecore/content/home" runat="server" />

To change the text of the link, you can use the Text property, but Link control is also able to render embedded content:

<sc:Link Field="Link" DataSource="/sitecore/content/home" runat="server">
  Link text
</sc:Link>

And of course  it can render child controls:

<sc:Link Field="Link" DataSource="/sitecore/content/home" runat="server">
  <sc:Image MaxWidth="200" MaxHeight="200" Field="Image" runat="server" />
</sc:Link>

The same using C#:

var link = new Link {Field = "Link", Item = Sitecore.Context.Database.GetItem(someId)};
var image = new Sitecore.Web.UI.WebControls.Image {Field = "Image", MaxWidth = 200, MaxHeight = 200};
link.Controls.Add(image);

MainPanel.Controls.Add(link);

Notice that controls also have the Item property. The difference between Item and DataSource is that one is designed for API use and accepts Item class, and the other is designed for declarative use and accepts strings.

All of the examples above support Page Editor, including the image nested inside link.

Saturday, November 15, 2008 4:19:55 PM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore | Crestone
 Monday, November 03, 2008

I’m starting on twitter at http://twitter.com/a_rusakov – I’ll experiment with format and content, but the primary focus is still Sitecore and everything related to it. It will not interfere with this blog, but hopefully supplement it in a useful way.

Twitter is a micro blogging platform, most known for limiting the length of one message (“update” or “tweet”) to 140 symbols, which dictates its own format. However twitter has also grown to a social platform with its unique flavor, supporting public conversations.

If you don’t want to use twitter but would still like to subscribe to (“follow”) my updates, you can use RSS.

Monday, November 03, 2008 12:39:04 PM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Personal | Sitecore
 Sunday, November 02, 2008

Sitecore 6 Update 6 is released, and the only fix is the support for uploading files with Flash 10 installed.

Download.

A little bit of insight: you probably heard that Adobe has introduced a new “security” rule in Flash 10 that says that Open file dialog can only be shown in a response to user interaction in flash. The rule effectively broke all javascript/flash uploaders, including the one we’ve used. The simplest hack around that rule is to overlay your HTML UI with a transparent flash object, and the updated flash-10-supporting libraries allow this overlay to be created using javascript.

As a positive side effect of having to redo the upload UI, uploading from media folder should open somewhat faster now. I’ve also switched our underlying library from SWFupload to YUIupload, which seemed like a better supported project.

Sunday, November 02, 2008 1:12:35 AM (FLE Standard Time, UTC+02:00)  #    Comments [2]
Sitecore | Web development
 Thursday, October 23, 2008

Today I’ve made google chrome a default browser on my laptop and work PC. I’ve noticed that I was spending more and more time in chrome for casual browsing, and when someone IMs me a link, waiting for Firefox to load is just a waste of time. Speed and sumplicity  finally won me over firefox addins.

From now on, it’s IE for Sitecore, Firefox for firebug and Chrome for everything else.

Thursday, October 23, 2008 3:54:55 PM (FLE Standard Time, UTC+02:00)  #    Comments [3]
Personal | User Experience
 Wednesday, October 22, 2008

We’ve released a major overhaul of the poll module. Improvements:

  • Sitecore 6 support, including using Page Editor to modify existing polls
  • New polls can be added using Sitecore 6 Page Editor
  • Staging support
  • AJAX voting
  • Fully automated installation
  • Simplified architecture: the module no longer uses an additional database, which also allowed us to completely remove the settings application
  • Better looks
  • Easier customization: we’re using more xhtml and css, and less tables. Instead of c# webcontrol code, we’re using an ascx sublayout that is much easier to tweak without having to compile the code
  • Refactored code and reviewed design

The Poll module is part of Sitecore shared source program, and it stays that way. However we’ve dedicated our QA and development to reshape the module and release a clean and well tested Sitecore 6 version. We used the same open svn/trac server for entire development process, and you can see change history.

From now on, the module continues its life as a shared source component, meaning that you can (and very welcome to) contribute. I was doing product management type of work on the project, while Michael Baranov gets all the praise for beautifying the code.

My favorite feature is the ability to add new polls directly through the Sitecore 6 Page Editor.

1. Click “Insert Poll”

image

2. Setup poll using a pop-up wizard
image

3. Select a placeholder

image

4. Done.

You can also edit existing polls from the Page Editor:

image

Content layout is changed, so that you’re no longer required to store all polls in a single location. This setup beautifully supports multisite solutions.

image

And bugs, lots of bugs were fixed:

image

 

Hope you like the update. Downloads, documentation and source code are all available at http://trac.sitecore.net/Poll.

Wednesday, October 22, 2008 5:13:12 PM (FLE Standard Time, UTC+02:00)  #    Comments [2]
Sitecore | Open Source
 Tuesday, October 21, 2008

I’m attending my first PDC this year, and I’m definitely up for a few drinks – let me know if you’re around. Email’s alexey at this domain.

Not quite sure what to expect from the conference –  looking forward to C# 4.0, User Experience and Silverlight talks.

Tuesday, October 21, 2008 10:00:30 AM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Personal
 Friday, October 17, 2008

Changes:

Issues fixed:

  1. Fixed: Cross site links were not working as expected. Such links now include the hostname of the target site and are generated relative to the start item of the target site. This functionality can be disabled by setting Rendering.SiteResolving to “false” in the web.config file.

  2. Fixed: a selected Publishing Target of an item was not taken into account when performing Publish operations.

  3. Fixed: The performance of item creation has been significantly improved.

New features:

  1. The FastQueryDescendantsDisabled setting has been added to the web.config file. It may be set to true to disable the ability to use fast query to select items through Ancestors/Descendants axes. This will give a small performance increase of item creation/moving/deletion.

 

Download.

Friday, October 17, 2008 10:12:02 AM (FLE Standard Time, UTC+02:00)  #    Comments [0]
Sitecore
Archive
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Blogroll
 Alex de Groot
Few words about SiteCore from Holland
 Alexander Shyba
Sitecore Support
 Anders Dreyer
Anders Dreyer on Sitecore Development
 Jakob Christensen
Sitecore Core Development
 Lars Fløe Nielsen
Lars's ramblings about development and business processes
 Ole Thrane
Sitecore API
 Runi Thomsen
Runi Thomsen Sitecore Toughts
 The Sitecore Experience
The Sitecore Experience
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Alexey Rusakov
Sign In
Statistics
Total Posts: 211
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, Alexey Rusakov
DasBlog theme 'Business' created by Christoph De Baene (delarou)