session 1: advanced content model wednesday 06 february 2007 sitecore for experts “sitecore skills...

38
Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Upload: scott-bishop

Post on 29-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Session 1: Advanced Content Model

Wednesday 06 February 2007

Sitecore for Experts “Sitecore skills for real men”

Page 2: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Introduction to the subject

1. Wildcard Items2. Linkdatabase3. Proxy items4. Discussion: Relations

Questions & Additional readingEnd

Today’s Program

Page 3: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Single simple modelExamples: Yoursite.com

2. Simple division divided modelExamples: Yoursite.com/Divsion1, Yoursite.com/Division2

3. Multi site modelExamples: Yoursite.com, Yoursite.nl, Yoursite.dk, Yoursite.fr

4. Multi language modelExamples: Yoursite.com/Int, Yoursite.com/nl Yoursite.com/dk

5. Multi languagal and site modelExamples: Yoursite.com/Int, Yoursite.com/nl Yoursite.com/dk Yoursite.be/Int, Yoursite.be/nl Yoursite.be/fr

Different Content Models

Page 4: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• Sharing of navigation• Sharing of layouts• Sharing of applications• Sharing of news• And legal content• Relations in different sites and languages• Thesauri?

Different models have in common…

Page 5: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Sitecore solution schematic

Page 6: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Wildcards items

Page 7: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• It’s required to allow all kind of url’s. Even those who doesn’t represent an item in Sitecore.• You want to make sure you can validate your input• Without using the QueryString, you are still possible to pass parameter trough (SEO)

The case

Page 8: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Solution: Wildcards

Page 9: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Item resolving in the pipeline

Page 10: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Good argument to prevent the usage of the QueryString

2. Ability to control the return messages such as 404’s.3. It’s processed in the Pipelines, so it’s easily

extendable.4. Protects you against possible security issues such as

database injections

Advantages:

Page 11: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Aren’t able to set restrictions, so you have to write lots of code* for right processing.

2. No native code* support3. It’s processed in the Pipelines, so it’s might cxause

some preformence(not fully cachable on DataProvider level)

4. It responds by default as a valid page(in headers) but in your opinion this might not be right.

5. Support is limited to 4.3 and 5.3

Disadvantages:

* Code in this context means XSLT/C#/…?

Page 12: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

    1 <xsl:template match="*" mode="main">    2   <!-- Retrieve the first level and display when exists -->    3   <xsl:variable name="level1" select="webutil:GetUrlName(0)" />    4   <xsl:if test="$level1 != ''">    5     <xsl:value-of select="$level1"/>    6     7     <!-- Retrieve the first level and display when exists -->    8     <xsl:variable name="level2" select="webutil:GetUrlName(1)" />    9     <xsl:if test="$level2 != ''">   10       &gt; <xsl:value-of select="$level2"/>   11     </xsl:if>   12   </xsl:if>   13 </xsl:template>

XSLT Usage Example

Page 13: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

<% Sitecore.Data.Items.Item currItem = Sitecore.Context.Item; int currLevel = 0; int maxLevel = GetWebRootLevel(); do { Response.Write(currItem.DisplayName+ "<br/>"); Response.Write(currLevel + "<br/>"); Response.Write(GetUrlName(currLevel) + "<br/>"); Response.Write("<hr/>"); currItem = currItem.Parent; currLevel++; } while (currItem.Parent != null && currLevel <= maxLevel); %>

C# Usage Example

Page 14: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

public string GetUrlName(Int32 index) {

string url = Sitecore.Web.WebUtil.GetRawUrl();

string path = url.Substring(1, url.LastIndexOf(".")-1);

string[] parts = path.Split("/".ToCharArray());

if (index < parts.Length) return parts[parts.Length - 1 - index]; else return ""; } public int GetWebRootLevel() { string path = Sitecore.Context.Site.ContentStartPath; return path.Split("/".ToCharArray()).Length; }

C# Usage Helpers

Page 15: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

2. Linkdatabase

Page 16: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

You want to have a full list:1.Family members in the Tree2.Items you do link to3.Items who links to you

The case

Page 17: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Solution: Linkdatabase

Page 18: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Easily access from the API (Item.Links, Sitecore.Links)2. Based on logical concept3. Very fast(no preformence penalties)

Advantages:

Page 19: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. ‘Native’ not supported for XSLT2. Seperated database, which implicates sync problems.3. Hard to extend4. Not all fields are supported

Disadvantages:

* Code in this context means XSLT/C#/…?

Page 20: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

private static Item[] GetFeedsInDatabase(Database database, Language language){   TemplateItem feedTemplate = database.Templates[Constants.FeedTemplateID];   if (feedTemplate == null)   {      return null;   }   // Get all items refering to the feed template   ItemLink[] links = Globals.LinkDatabase.GetReferers(feedTemplate.InnerItem);   if (links == null)   {      return null;   }   ArrayList result = new ArrayList(links.Length);   // and filter the referers - we dont need to include masters   foreach(ItemLink link in links)   {      if (link.SourceDatabaseName == database.Name)      {         Item item = database.Items[link.SourceItemID, language];         if ((item != null) && (IsMaster(item) == false))         {            result.Add(item);         }      }   }   return (Item[])result.ToArray(typeof(Item));}

C# Example

Page 21: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Where would you use this?• ‘Related to’ links on the bottom of news/articles• Navigations (Item groups, etc)• As the technical basis for a Thesauris solution• Others?

Possible cases

Page 22: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

3. Proxy items

Page 23: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• You want to reuse content nodes in different trees or sites.• For SEO, you want to make sure /sitecore/content will not appear in URI’s.Or• Divide navigation management from content

The case

Page 24: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Proxy Items…

The solution

Page 25: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• Source item: The item to copy it from• Target item: Place where the item will be located• Exclude subitems: In or exclude subitems• Source database: Might be any database

Proxy template

Page 26: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Creation of Proxy items

Page 27: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Very fast as virtual items are also cached in the dataprovider

2. Easily to configure in the client(even more simple module available)

3. Very powerfull as the API seems to think it are real items

4. Ability to publish virtal items to real items for preformence improvements

Advantages:

Page 28: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

1. Solution seems to change in every version of Sitecore?

2. Might be confusing for users3. There are no visible possibilities to select an item in

another database

Disadvantages:

Page 29: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• Item.RuntimeSettings.IsVirtualIndicates whether the item is a virtual item or not.

• Item.RuntimeSettings.IsExternalIndicates whether the source item is from a database other than the target database.

• Item.RuntimeSettings.OwnerDatabaseThe database that owns the source item. Note the Item.Database property will always return the target database!

Programmatically enable or disable proxies:• bool Sitecore.Context.ProxiesActiveEnable (set to true) or disable (set to false) proxies for the current session.

• Sitecore.Data.Proxies.ProxyDisablerDisable proxies for a block of code.

using (new Sitecore.Data.Proxies.ProxyDisabler()) { // Proxies disabled here}

Proxies in the API

Page 30: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

4. Discussion: Relations

Page 31: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

You want to create a collections of items, which aren’t always linked.

This collections should be changeable. And is the members of this collections should ofcourse be defined by your own criteria.

The case 1

Page 32: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

That’s up to the experts…1.What are the requirements?2.What do you want to store?3.Where do you want to store it?4.How should it be retrievable?

The solution?

Page 33: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

You want to create a collections of items divided by keywords or

maybe the alphabet. Preformence is not an issue.

How can we solve this?

The case 2

Page 34: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Some review questions:1.What kind of relations are available in Sitecore?2.Why do you want to introduce more relations?3.Are the examples provided clear? Do you have a better example?4.What would be a nice addition to Sitecore for extending the content model?

Next steps: Think about it!

Page 35: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

• http://sdn5.sitecore.net• http://www.lfn.dk• http://www.alexeyrusakov.com/sitecoreblog/• http://sitecore.alexiasoft.nl

Next steps: Additional reading

Page 36: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

This is your last change…

Questions?

Page 37: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Next month…

In the Sitecore API

Page 38: Session 1: Advanced Content Model Wednesday 06 February 2007 Sitecore for Experts “Sitecore skills for real men”

Thank you for your attention!

And please, think about it and spread the word…

Mistakes, corrections and additions can be mailed to Alex de Groot: [email protected]

The presentation is part of LECTRIC / Alex de Groot but can be used without any premission.

The end…