I’m sure there are a lot of variation implementing content tree structure out there, here I’m sharing the content tree structure that i have grown liking to.
The idea is to keep things simple and organized for the content editor so they can work their way around the site and feels natural about how the content is structured.
We start simple, a website node has two child node, a home page node and a libraries node.
A home page node serve as the landing page when the site URL is accessed, a libraries serve as a place to put the data sources of components that’s being used through out the site.
And there’s pretty much how content tree is structured, as a convention i usually use lowercase and no whitespace for the pages node item name because that translate directly into a URL, so you want a friendly URL to be generated. You can enforce this by using a custom pipeline that change the item name after creation and update but convention is good enough for me.
For the pages under supplementary pages, these are the pages that do not belong to the site’s pages hierarchy/sitemap and usually i give them alias so we can achieve URL such as /404 instead of /supplementary-pages/404. It’s just a matter of taste but think about it.
Hey, what about multisite ?
What about it ?, we replicate the same structure for the other sites and if you notice we have a global node over there. The global node serve as a place to put shared content across the sites, maybe the sites shared the same banner data source or carousel put it in the libraries of the global node. And that also goes for the shared pages, you can put it in the supplementary-pages of the global node.
The same structure can be found on other places as well
also keep in mind these following things:
- if you have a need of referencing items avoid referencing by item path and use item id instead because item path can change, for example when the content editor move the item around or rename them.
- remember that it’s a bad practice to have hundreds of child nodes under a single node, use categorization to manage them – see news page above.
- if there’s a need to store a huge amount of data that results in hundreds of child nodes don’t try to store it Sitecore as is, give it a thought and see if storing in a custom table suit your requirement better or take a look at the Sitecore Item Bucket.
- use branch template to specify a content structure.
- use insert options to specify child node type that can be inserted under a node.
- use icon to give visual information to your content editor, this way they can easily distinguish which is which, but be wise in the implementation don’t just give any random icon.
If you implement a separate server for Content Management Server (CM) and the Content Delivery Server (CD), it is advised that you disable the file based media storage so that CD can retrieve the image information.
The following code shows how to update the existing file based media to database storage, from it you could create a Sitecore app to make a handy tool to update your existing media files.
Often enough we build a functionality in Sitecore by utilizing the Sitecore task scheduler, something like, send an email when this user hasn’t updated x in y number of days.
With the sitecore task scheduler i’ve been struggling to test the functionality, because in Sitecore i cannot trigger the scheduled tasks manually. So what i did was set the schedule as low as 1 sec interval and then just wait until the the process hit my breakpoint.
Luckily i’ve found this little gem of tool, the “Scheduled tasks utils”. This tools will list available task in your database and there’s a little button to execute the task. just what i need!
Was playing around with Sitecore 6.5.0 rev. 120427 and .NET 4.5, first thing that happen is I got this error.
Object of type 'System.Int32' cannot be converted to type 'System.Web.Security.Cryptography.Purpose'
it seems that this has been fixed in Sitecore CMS 6.5.0 rev. 120706 (6.5.0 Update-5), but for those who want to do workaround for it, here’s what you can do.
add this line to the web.config
<setting name="login.rememberlastloggedinusername" value="false" />
Team Development System for Sitecore is one of the best thing that happened to me in developing with Sitecore and here’s why.
Checkout the following diagram from http://www.hhogdev.com
it says it all. There’s no more manual packaging and deploying that package to the target environment. Instead we as a team manage our changes through the source control system
Comparing the changes through the source control history –the display depends on the merge tool that you use, i’m using WinMerge in this case.
And when we’re planning to do deployment to target environment we just need to make sure that we set that in the project properties and TDS will take care of the rest.
Like one of my colleague said, “i can’t imagine developing sitecore without TDS anymore” though sounds like one of those advertisement line it does hold some truth to it.
Found a very strange behaviour with Sitecore image control, take the following code
<sc:Image runat="server" ID="img" Height="200" Width="300"/>
i would expect that would render the img tag with the correct height and width, but instead it renders out this
<img src="/~/media/Images/websitename/Images/1.ashx?h=120&w=160" alt="basics" width="160" height="120">
it overrides the height and width that i set and take the image height and width.. odd indeed
luckily we have a way to overcome this without having to use custom control or having to resort to asp.net image control – we would like the support the page editor functionality.
Set the parameters explicitly
That’s right, we need to set the parameters explicitly so that it renders out the correct value.
First, remove the Height and Width attribute from the markup
<sc:Image runat="server" ID="img"/>
then in the code behind
img.Item = item;
img.Field = "Big Image";
img.Parameters = "w=200&h=300";
and here’s the result
<img src="/~/media/Images/Website/Images/1.ashx?h=300&w=200" alt="basics" width="200" height="300">
Just like what i wanted.
If you’re wondering what other parameters are supported by the image control, you could find that in the Sitecore SDN
i’ve spend the last couple hours trying to figure out what’s wrong with my code. I was trying something simple, getting an item from the Sitecore Web database. Which turns out not so simple after all, frequently i cannot retrieve any field values from the item that i retrieved.
After a long time trying out different things, renaming the section, rename the item name, change the template, change the content tree structure, checkout if any custom pipeline might be the isssue…
It turns out that this line of code -which looks ok at first glance- has an issue
// create new database instance
Database database= new Database("Web");
// get item
var item = database.GetItem(itemId);
// get the field value
var value = item.Fields["My Field"].Value;
in other area of the software that we develop we were using this code to get the database instead
Database database = Database.GetDatabase("Web");
it turns out that those two ways of getting the database instance is totally different from what i originally thought.
By using the constructor approach we only create an empty database object while using the latter approach it will build the database instance with all of the configuration values within the config file via reflection.
thanks to this Stackoverflow post my misery has ended.