Archive for the 'sitecore development' Category

17
Nov

Sitecore performance, too many items read, load times are too long

Hey guys,

after a couple of hours searching, testing and debugging a complete (pretty nice) international (>20 languages) solution we still experienced a (at this point) strange behaviour by Sitecore.

Imagine that:

Root
- subitem 1
- subitem 2
- subitem 3
- subitem 4
- subitem 5
- subitem 6

All these subitems have no(!) fields. And there are no proxies or any other things which can influence the performance. How long does it take to evaluate this xpath statement: ./item (the context node is the root node)?

It takes approx. 19 ms! So long for such a basic operation, wtf? (Also in the profiler view we see approx. 3000 items read)

… some random time later (after changing the icon as well ;-) ) …

Check the “Subitems sorting” field on the root item! In our case the value was “Created”, if you set it to default (or nothing) it takes 0,12 ms!

Checking the code of the “Created” method reveals the explanation: By each call of DoCompare() it compares each version as well. Now: 24 languages with 1 version and 8 subitems…. now it’s quite understandable why it took so long. Also the items count in the profile are less!

So, be careful when applying “Created” as subitems sorting on a large enviroment.

Enjoy the rest of the week.

best chris

25
Sep

Page Editor conflict with master pages

Hey guys,

just a short note. After coming across the known issue that the page editor fails with master pages. I want to remind you that’s always useful to check the known issues after stumbling on a weird bug.

Anyway, the Sitecore Support always helps you finding a solution, even if you didn’t take a look at the known issues first :-) . Thanks.

Best, chris

07
Sep

sheer ui: create webedit ribbons (part 3)

Hey guys,

let’s get back to the blogsphere by writing again. After the sumer hole 2009, the autumn seems to start in Germany. A lot’s of stuff happened in the last time: The OMS release, Sitecore 6.1 and I’ve passed my Sitecore Trainer Exam.

Thanks again Alex, Bert, Peter and Sven. :-)

Like in the first post of this series. I show you the different Sitecore Buttons which you know already, I guess.  

  • Large Combo Button: The field “Gallery” specifies the control id of the “Menu” to display. The control is a xaml file like any other “sitecore client xaml application”. The code looks like this:

<?xml version=”1.0″ encoding=”utf-8″ ?>
<control xmlns:def=”Definition” xmlns=”http://schemas.sitecore.net/Visual-Studio-Intellisense“>
  <Gallery.WorkflowEdit>
    <Stylesheet Key=”Gallery.WorkflowEdit”>
      body {
      height:auto;
      }
    </Stylesheet>
    <Gallery>
      <CodeBeside Type=”Sitecore.Shell.Applications.ContentManager. Galleries.WorkflowEdit.GalleryWorkflowEditForm, Sitecore.Client”/>
<Menu ID=”Options” Border=”none”/>
</Gallery>
  </Gallery.WorkflowEdit>
</control>

  • Panel: The complete layout is specified in the code behind. The type field is where your <namespace + class name>,<assembly name> goes in. Here “Sitecore.Shell.Applications.ContentManager.Panels.NewPanel,Sitecore.Client”. The code is pretty long though, but the important thing is that you have to inherit the “RibbonPanel” class and override the Render method.

public class NewPanel : RibbonPanel
{
    // Methods
    public NewPanel();
    protected virtual string GetClick(Item item);
    protected static UrlString GetUrl(Item item);
    public override void Render(HtmlTextWriter output, Ribbon ribbon, Item button, CommandContext context);
    private static void RenderOptions(HtmlTextWriter output, List<InsertOption> options);
}

  • Large Menu Combo Button: The Items which build your menu, are of the “menu item” template. You can pass the id of the current item by using parameters like this: “item:deletechildren(id=$Target)” (The delete children menu).

Hope I could bringt some light into the dark. I already got another idea about topics to write about, so stay tuned.

Best, Chris

26
Apr

sheer ui: create webedit ribbons (part 2)

Hey guys,

here we go again. So after we know all relevant items and templates we can now go to create some and demonstrate how easy it is (after you know how :-) ).

Let’s create a chunk to demonstrate how to create your own strip:

/sitecore/content/Applications/Content Editor/Ribbons/Chunks: You find all existing chunks in Sitecore here. To create your own: Insert a new Item of the type “Chunk” (/sitecore/templates/system/ribbon/chunk). There are different fields in the data section (You have to scroll down to see them.).

  • Header: self explaining, isn’t it? - It’s the text below the buttons
  • Click: That is a command field, for my series I will call it that way. Commands are strings which are definied in App_Config/Commands.config. You have to specify the name and the type attribute.
    Be careful: The name has to be lower case!
    The type is “<namespace>.<class name>, <assembly name>”. This type is the link to the class which inherit the command class (Sitecore.Shell.Framework.Commands.Command). You have to implement the abstract method: public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context). The context parameter passes the current item in context.Items[0] (mostly, I didn’t find any methods where it is not).
    If you fill a value there, you will get a clickable header on the bottom, like the insert chunk where you can set your allowed templates.
  • Access key: Does not make sense for me, though. I don’t know how to move to a chunk by having an access key. Also I did not find any examples for this behaviour in Sitecore. Maybe some Sitecore devs can tell me more about it.
  • Tool Tip: Same here. I can’t find where it is displayed when I filled it with some value.
  • ID: Now get back to the important fields. This field has to be unique and no white spaces in it. I think you all know element ids and the requirements. I’m always using “<myChunkName>Chunk” as the value.

After you did this, you have your own chunk without any buttons. I will get back to the possible buttons and panels in my next post by demonstrating all buttons.

Let’s see how to integrate your own strip with your empty chunk. Go to Ribbons/Strips and create a new item of the type “Strip” (/sitecore/templates/system/ribbon/strip), there you have different fields:

  • Header: Self explaining, the title of the strip
  • Contextual Header: Sorry, but I can’t get this to work. If anyone knows how to use this field, please add a comment.
  • ID: Same as above, unique id of the current element.
  • Access key: Type a char in there and you can access your strip by pressing [alt] + <your Access key>
  • Tooltip: A tooltip next to the header of your strip.
  • Type: Of course you can create a dynamically strip which could be personalized, pulls something from an external database etc. The type is in the “normal Sitecore format”: <namespace>.<class name>, <assembly name>

Great! So far so good. After you created your strip, you need to let the strip know which chunks are in there. That’s why we created an empty chunk first. Under your strip you have to create a new item of type “Reference” (/sitecore/templates/system/reference) and give it the name of your chunk. There you will find a field called “Reference”: link your chunk here.

Now, if you want to see your strip in the Sitecore Client Content Editor, you have to go to …/Ribbons/Ribbons/Default and create a new item of type “Reference“, give it the name of your strip. Link your newly created strip item in the reference field.

After you saved the current item, you can right-click on your ribbon navigation and should now see your strip unchecked. If you click on your strip, it will get inserts in the content editor.

Other locations like WebEdit / Preview or Debug are also possible, I will tell you where in my next posts. As well as all possible buttons and panels you can add.

Have a nice sunday, I will go out for some sports now and enjoying the sun :)

cheers chris

21
Apr

Sheer UI: Create webedit ribbons (part 1)

Hey guys,

sorry that I didn’t write anything for a while, but I digged myself into a couple of books for my study.

The last days I worked to customize the webedit ribbon bar and added my own functionality. I really like working in the sheer ui and hopefully there come more tasks to tackle and I can write about them.

Here we go, everybody of you know the new webedit in Sitecore and the ribbon (button) above. I want to create a new strip (like “Page Editor” and “Home”) and in there I want a new chunk with a panel.

Ribbon structure
Here you see the Ribbon structure in Sitecore. It may be useful. :-) Now, your new friend is the Sitecore Core database and the Item: /sitecore/content/Applications/Content Editor/Ribbons; there you find all the relevant items you need to create or change. In there are different folders:

  • Chunks - defines all different chunks. If you want to create a new one, this is your first point.
  • Contextual Ribbons - You remember the context ribbons e.g. when you create a new template, this is done here.
  • Ribbons - under Default you can define the default strips you have in your normal content editor and if they are hidden by default (right click on the toolbar you see the developer and my toolbar which are hidden by default for example).
  • Strips - In the image above you see that this whole thing is strip. Define it’s details and chunks here, but I get back on that later.

Unfortunately I have not that much time at the moment, so I will split up this tutorial into several parts. Check back soon to see how to connect these items and see it in action. I will also describe how to create a panel such as insert, where you can change the behaviour programmatically.

cheers chris

17
Feb

Language embedding in urls

Hey there,

Sitecore 6 provides a functionality to embed your language as parts in the url e.g. http://www.test.com/en-US/test.aspx.

You can control this feature by using the web.config entries:

<linkManager defaultProvider=”sitecore”>
   <providers>
    <clear/>
    <add name=”sitecore” type=”Sitecore.Links.LinkProvider, Sitecore.Kernel” addAspxExtension=”true” alwaysIncludeServerUrl=”false” encodeNames=”true” languageEmbedding=”asNeeded” languageLocation=”filePath” shortenUrls=”true” useDisplayName=”false”/>
   </providers>
  </linkManager>

Cheers chris

13
Feb

Breaking xslt paradigm

Hey guys,

writing xslt is some kind of special, isn’t it? As a original developer who started with php need to pay special attention to the xslt paradigm.

In my case I have a dropdown navigation with two columns after each 4 items where you need to split the current div tag into a new.

You can’t do something like this:

<xsl:if test=”position () = 4″>
</div><div class=”Submenu”>
</xsl:if>

Right?

The solution is some kind of “hack”, so only use this if you have tried to think over your code and another solution.

<xsl:variable name=”divider”>
  <![CDATA[</div><div class=”Column”>]]>
</xsl:variable>

Now you can do:

<xsl:if test=”(position() mod 4) = 0″>
  <xsl:value-of select=”$divider” disable-output-escaping=”yes”/>
</xsl:if>

Enjoy ;)

10
Feb

Sitecore query in template source fields + language

Hey guys,

if you have:

  • A template with a dropdown (or droplink field)
  • A second template with a checkbox field

You want to have: An item based on the first template with a dropdown where only items are displayed which have the checkbox checked.

My source is:

query:/sitecore/content/home/Site/#Ueber-Uns#/Team/*[@is contact=’1′]

First you have to keep in mind that item names with “-” dashes should be covered by “#” else you get the exception: Invalid lookup source …

Second (if you operate with a second language - here: german): If you don’t get any results, mark the checkbox as shared. In some way the query doesn’t select the correct language from my point of view.

cheers chris

12
Dec

Create application links in the sitecore startmenu (don’t work)

Hey guys,

in my current project I have created a very simple Sitecore client application to manage newsletter (I will write a documentation how to work with xaml hopefully soon.). After the whole application work I want to link this app in the Sitecore start menu for every user.

If you want to do this, you have to:

  • Go to the core database
  • Open: /sitecore/content/Documents and settings/All users/Start menu/Left
  • Create a “Application shortcut”
  • Fill the fields: Display name, Tool tip and apply security rights (if you want to enable this link just for groups or user)

Now the tricky part: The “Application” field:

  • Click on Insert Link
  • Select your desired app
  • Click “OK”

So far, everything is fine. If your link don’t show up. Go to the view ribbon, click on “Raw values” and go to the application field.

Change this:

<link text="Demo App" linktype="internal" url="/Applications/Demo App.aspx" id="{007BA8C3-3C1D-4569-90B1-DC7F0A0A4689}" />

To:

<link text="Demo App" linktype="internal" url="/Applications/Demo App" />

So remove the “.aspx” and the id parameter, and save. After this change and a reload of the client your link should show up in the start menu.

cheers chris

28
Oct

sitecore website login / restrict sites for anonymous *update*

Hey guys,

if you are trying to restrict special sites for the extranet\anonymous user, so only authenticated users (doesn’t matter if it’s a virtual user or a real user account) can view that content.

You can restrict the read right for the anonymous user and add an (undocumentated - the reason I write about it ;-) ) attribute to your site in the web.config. The default one will be website I think.

loginPage=/sitecore/content/home/Registration/Login.aspx

It can also be a sitecore Item and you refer to the virtual path. So after Sitecore sees that the user is not autenticated, it redirects the user to your login page. Unfortunately it passes own query string parameters, and none of them is “returnUrl”. In my case I hooked into the httpRequest pipeline right before the ExecuteRequest processor and created my own SecurityResolver.

[updated]

    public class SecurityResolver : HttpRequestProcessor 
    {     
 
        public override void Process(HttpRequestArgs args) 
        { 
            // Get the site context 
            // [CW] 
            SiteContext site = Sitecore.Context.Site;          
 
            // Check if the current user has sufficient rights to enter this page 
            // [CW] 
            if (SiteManager.CanEnter(site.Name, Sitecore.Context.User)) 
            { 
                string prefix = args.StartPath;          
 
                if(args.LocalPath.Contains("/sitecore/content/home")) 
                    prefix = String.Empty;          
 
                if (Sitecore.Context.Database != null) 
                { 
                    Database contextDatabase = Sitecore.Context.Database;          
 
                    Item contextItem = null;          
 
                    // Get the item using securityDisabler for restricted items 
                    // [CW] 
                    using (new SecurityDisabler()) 
                    { 
                        contextItem = contextDatabase.SelectSingleItem(String.Concat(prefix, args.LocalPath)); 
                    }          
 
                    // Check if a loginPage is given 
                    // (Should be for this website) 
                    // [CW] 
                    if ((contextItem != null) &amp;&amp; (contextItem.Access.CanRead() == false) &amp;&amp; (site != null) &amp;&amp; (site.LoginPage.Length &gt; 0)) 
                    { 
                        // Redirect the user 
                        // [CW] 
                        WebUtil.Redirect(String.Format("{0}?returnUrl={1}", 
                            site.LoginPage, 
                            HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.RawUrl))); 
                    } 
                } 
            } 
        } 
    }

Hope it’s helpful for you - You may also post questions or interests. I’m looking forward to develop a sitecore client application with xaml, and can manage to documentate the steps I do.

cheers chris




September 2010
M T W T F S S
« Mar    
 12345
6789101112
13141516171819
20212223242526
27282930  

Recent Entries