Saturday, September 4, 2010

Sitecore Fetch Squad

Automated crawler fetching websites and blogs from Sitecore content

Archive for the ‘Featured’ Category

When Will Sitecore Adopt ASP.NET MVC?

Posted by admin On February - 3 - 2009

I followed the ASP.NET MVC development since it first appearance on the ALT.NET conference in the end of 2007 and as you can see from various posts, I’m a big fan of it (ASP.NET Web Development - some thoughts… -and- A Conceptual Alignment of Sitecore, ASP.NET WebForms, ASP.NET MVC and the Microsoft AJAX Client-side Library). From an architectural point of view as well as from a lead developer point of view, MVC is and has always been the best server-side pattern for web applications (and as long-standing Java EE and Rails developer I’m allowed to say that). In combination with event-driven GUI frameworks on the client side like ASP.NET AJAX, JQuery and Silverlight it should always be the first choice for every serious web developer in 2009. It is also an important building block of our Reference Application Architecture and Microsofts Application Architecture Guidance 2.0, especially in combination with WCF.

The question is now: When will Sitecore finally adopt ASP.NET MVC as supported framework? Clearly there is no doubt that the development model of ASP.NET MVC and Sitecore are even closer aligned than the development model of ASP.NET WebForms and Sitecore and that there are enormous synergistic effects by integrating both frameworks. This is true for various parts of the system, especially routing and rendering (where XSLT was - beside other reasons - chosen because "inline code" was a bad thing back than). I personally expect not only basic support for ASP.NET MVC but even a complete switch to use it as primary base framework instead of ASP.NET WebForms over the next couple of months, maybe a year.

Julius Ganns . netzkern

typesThatShouldNotBeExpanded

Posted by admin On January - 29 - 2009
After having ran into this myself a few times, and for the 5th time being asked by one of my Sitecore friends; I though I would bring this one up.

Ever had trouble getting your ASP.NET ListView controls to retain ViewState or do standard Paging?

As many of you will know, Sitecore’s web.config is a source of endless configuration fun. Sitecore’s modular nature is basically founded on this configuration - want to switch something around or change how Sitecore works (at your own risk, usually, but that’s ok)? Web.config is the place to go.

Many of the settings are self explanatory and well commented, so working out what they do is fairly straight forward. In some cases, they are not, however.

If you look through, you will find an element named “
typesThatShouldNotBeExpanded”.

In it you will find two entries:

  • System.Web.UI.WebControls.Repeater
  • System.Web.UI.WebControls.DataList

And while I don’t have enough insight into exactly HOW Sitecore ties in to the ASP.NET lifecycle to determine exactly WHY this setting is needed, I can however tell you what happens if you don’t fully control it.

Say you have a control, where you drop in an ASP.NET ListView Control. Or a GridView control. They’ll appear to work fine at first, but you’ll quickly notice that paging and viewstate is acting up a bit on your controls.

The fix for this is easy, and as far as I know this is well known by Sitecore Support. Add your controls to this - almost black magic like - web.config setting, and you’re set :-)

So

Add System.Web.UI.WebControls.ListView, and System.Web.UI.WebControls.GridView to this collection if you find paging, viewstate or other things “that normally works” doesn’t.

I don’t know when this setting was introduced, or even IF there is a reason Sitecore doesn’t include these common controls in the list. Maybe there’s a negative effect on performance or otherwise.

Searching on the web only produces this one link (searching on SDN, two results but similarly without explanation), and that doesn’t tell us anything else than the config setting was apparently introduced in Sitecore 5.3.2 071220.

Into the core

Contributing to Sitecore Shared Source Projects

Posted by admin On January - 29 - 2009

The following tips for working with Sitecore shared source are based on my recent experience contributing the FieldValueComparer (based on to the comparer in this post) to the Sitecore Shared Source project.

  • Review this introduction to contributing shared source to obtain access to Subversion or to request a new project room.
  • Each project room is basically a Wiki. The only way back to the list of project rooms seems to be http://trac.sitecore.net/Index, so most project rooms include this link.
  • Review this guide to contributing shared source.
  • Copy files into the Trunk directory and check them in.
  • I don’t like learning a new markup, but when editing the Wiki:
    • It seems to format linefeeds as HTML paragraphs or line breaks.
    • Use equals signs for major headings (the spacing seems to be important): 
      = heading =
      
    • Use more equals signs for minor headings:
      == heading ==
      
    • Preceed text with an exclamation mark to avoid the Wiki automatically creating a link:
      = Welcome to the !ProjectRoomName =
      
    • Wrap URLs with quare brackets, optionally followed by a space and the text of the link:
      [http://sitecore.net Sitecore Marketing Site]
      
    • Wrap code with three curly braces to preformat it for easy copy and paste:
      {{{
      // code
      }}}
      
    • You can create entries in numbered lists by entering a space character, a number, and a period on a blank line:
       1. First.
       2. Second.
      
  • Please report issues and feature requests for shared source components by posting on the Shared Source Modules forum on the Sitecore Developer Network.

I will try to maintain this list and the FieldValueComparer project room as a template for cutting and pasting when creating new projects.

John West Blogs about Sitecore

About Data Driven Websites and Object Relation Modeling

Posted by admin On January - 29 - 2009

I’ve reinstalled my machine of last night with Windows 7. I’m very happy with this new platform… Thank you Microsoft. One of the final reasons to start yesterday was that my database integration in Visual Studio was broken. Of course there where many more reasons, but that was the issue which made me do it yesterday evening.

So far so good. This morning I started of with a clean and very fast machine. Visual Studio 2008 was ready to roll. I’ve installed the Developer Edition of VSTS yesterday eve.

Today I decided to spent a little bit of time on getting the Entity Framework to work for a small, highly data-driven portal I’ve to develop. One of the issues with the portal is that it should be ready by yesterday. Not so much pressure, but I wanted to be highly productive. Unfortunately I’m highly disappointed.

While we all still claim that simplistic data driven websites should be online in a couple of hours, the truth is the opposite. I’ve got an app where you’ve got users. Users can be in a WorkGroup and some of those these users are leaders of the group. In objects:

  • User.WorkGroups –> List<WorkGroup>
  • WorkGroup.Users –> List<User> –> All users associated, incl leaders.
  • WorkGroup.Leaders –> List<User> –> All leaders

In the database you’ll store this as 3 tables: User, WorkGroup and an AssociationTable with a property ‘IsLeader’ (bit).

The database design was easily made, as I told you before, I decided to use the Entity Framework. But somehow I was absolutely unable to get this to work. I could get the User <-> WorkGroup(many to many relation) to work, but the Leader-relation couldn’t be made without modifying the generated code(or maybe the XML?). 

I’m sure one of you guys will give me the solution how to get this to work. And once again absolutely sure that this is not impossible. But I’m in general wondering why I couldn’t figure this out during the 2 hour R&D I’ve spent on it. The designer doesn’t seem to support something like that. Or it is hidden, somewhere. I’m not sure if this is just a limitation of the Entity Framework or of many O/R mappers.

I do know I generally dislike my whole process. I’ve been switching over and over between the different designers for my entities and database. This makes me wondering. What if this is your daily task? Getting a model designed by business users(interpretation I), normalize this(interpretation II), fit this into an object design(interpretation III) and maybe redo some of these part during one of the stages.

Let’s look from a perspective of a developer. I do not care about the database. It should just be stored. I care about the way I can access the data, so I want to control the types in my entities. My illusion: create a model(we’ve got a language for that: UML). Hit a button, and code + database should be ready.

Optimizations for storage and in the data access code should be done by the generation. The computer is way smarter when it comes to optimizing, it can calc all data access roads and ask if I want to flag more often used data. When I want to create a specific method(for example: GetById) I can define it in OCL.

The solution seems to be so obvious. Why can’t I find such a tool? I can find database generation tools, I can find O/R mappers. I can even find frameworks which should be O/R mappers(isn’t the Entity Framework the framework to be?). But none of these support my vision.

What can I do know? I can use a CMS to store my relational data. All my relational data, maybe thousands of records. I’ve to find a way how to store it internally as CMS’s use all kind of structures, but never a relational one.

I’ll end up in this project using an heavily modified Sitecore installation with lots of custom code to get around the limitations(I’m able to write that quickly as you can imagine). But hopefully you’ve seen my point. I gives me a huge headache in this age of data generation, web service generation for out scaling, advanced cache structures, cloud computing, etc.

Do you got a solution in mind for me?

Note: This is a post written out of my experience as an architect in many projects. I’m involved in general in Sitecore projects, but rarely I’ve got the opportunity to ‘work’ a little outside of this boxed environment. Often these high level problems arise as well in project where Sitecore is involved. I won’t blame a vendor, but I’m wondering why we smart guys are not able to solve issues like productivity without doing concessions on the business requirements.

.Sitecore

Custom Sitecore fields and master templates

Posted by admin On January - 29 - 2009

For a client I had to write a custom Sitecore field. The field was to contain a number that incremented every time a new item using the field was created. I created the field and so that they could seed the number created a Sitecore item that contained the current highest field number.

This worked great for a few days but then during testing for some reason the field stopped incrementing and always used the same number. After a bit of investigation I realised that this was caused by a value being set on master template. My code worked by checking to see if the field had a value and if not setting a value using the seed:

 	    if (!Sitecore.Context.ClientPage.IsEvent)
            {
                this.isEvent = false;

                if (string.IsNullOrEmpty(this.Value))
                {
                    this.Value = GetNewValue();
                }                            

                this.Controls.Add(_SeedValue);

                _SeedValue.ID = GetID("SeedVal");
                _SeedValue.Enabled = false;
                _SeedValue.Disabled = true;
            }
            else
            {
                _SeedValue = FindControl(GetID("SeedVal")) as Edit;               

                this.Value = _SeedValue.Value;
            }

What my code did not do is check that the current item being editted was not a master. To do this I had to add the following:

private bool IsMaster(Item item)
{
	if (item == null) return false;
	else if (item.ID == new Sitecore.Data.ID(new Guid("{BAD98E0E-C1B5-4598-AC13-21B06218B30C}"))) return true;
	else if (item.Parent != null) return IsMaster(item.Parent);
	else return false;
}

This method checks to see if the current item being edited is a descendant of the Master item. The guid in the method is the guid of the Master item. Unfortunately you can not check the template of master of the item being edited because a master is based on the template that it is the master for and is not made from a master itself.

The main code then changes as follows so that only if the field is blank and not a master should a value be generated:

            if (!Sitecore.Context.ClientPage.IsEvent)
            {
                this.isEvent = false;

                Item edittingItem = Sitecore.Configuration.Factory.GetDatabase("master").GetItem(this.ItemID);

                if (string.IsNullOrEmpty(this.Value) && IsMaster(edittingItem) == false )
                {
                    this.Value = GetNewValue();
                }                            

                this.Controls.Add(_SeedValue);

                _SeedValue.ID = GetID("SeedVal");
                _SeedValue.Enabled = false;
                _SeedValue.Disabled = true;
            }
            else
            {
                _SeedValue = FindControl(GetID("SeedVal")) as Edit;
                this.Value = _SeedValue.Value;
            }

Also be sure to use

Sitecore.Configuration.Factory.GetDatabase("master").GetItem(this.ItemID);

If you try to use

Sitecore.Context.Database.GetItem(this.ItemID);

You will have problems because the current context is set to the Core database.

Mike’s Blog

The curse of the PNG’s

Posted by admin On January - 21 - 2009

When Sitecore released version 5.0 of the CMS, it included a major overhaul of the design in the editor, which featured a set of icons purchased from an external icon design company. These PNG icons are also included in the version 6 of the CMS.
Sitecore already in version 5 decided to include the complete icon package into the software, although only a subset of the icons were used – why? Maybe as a service towards the developers or maybe just because it was easier for them just to include them all, who knows. Anyway, the complete icon library can be used – and in version 6 even browsed – from with the Sitecore editor. Nice feature - but from my point of view, at a very high price.

The following table shows the number of files, just in the /sitecore/shell/themes/standard folder for some randomly picked versions of Sitecore CMS:

Version 5.0:    11.100 files
Version 5.2.0:    13.357 files
Version 5.3.0:    13.745 files
Version 5.3.2:    18.133 files
Version 6.0:    18.244 files
Version 7.0:    ??

I have about 5-10 different Sitecore projects on my hard disk which I am actively working on, I constantly create and delete Sitecore projects for testing purposes and our build system continuously and nightly surveys, builds and copies 20+ active Sitecore projects in our company. All of these tasks are heavily burdened by the icon library.
A clean Sitecore 6 version contains approx. 24.000 files of which approx. 18.000 are icons (and approx. 5.000 are related to the HTML editor). This means that 75% of the files in Sitecore are icons. In terms of megabytes, this number is only 40%. But still, you get my point?

Sitecore, please, please, please consider alternate ways of including the icon library. How about a compiled resource with all the icons? Or maybe included in the media library in the core database? Whichever way you choose, the life of me – and a lot of my fellow Sitecore developers - will be so much easier. Thank you!

      

Molten Core

jQuery conflicts with PageEditor

Posted by admin On January - 21 - 2009
There is such problem, indeed. It is caused by the conflict with Prototype.js that most of Page Editor, including designer and debugger uses. It can be simply worked around by overriding the $-function by calling "jQuery.noConflict()". <script type="text/javascript" src="/js/jquery-1.2.6.js"></script>

 

<script type="text/javascript">

 

var $j = jQuery.noConflict();

Consulting and Supporting Sitecore Developer Community

Maximum number of Sitecore query items

Posted by admin On January - 21 - 2009
Last week I had some problems with an Sitecore Query. It didn’t show more than an fixed number of items. After some hard thinking I rembered that there is a web.config key called Query.MaxItem which, you might guessed it, controls the maximum number of results of an Sitecore Query.

Mark van Aalst

Sitecore Seminar - February 6, 2008

Posted by admin On December - 29 - 2008

Setting the value of a Lookup field

Posted by admin On December - 29 - 2008
How to set the value of a Lookup field programmatically.

Sitecore Code Snippets