Borj
Borj

Reputation: 43

Using an Item as data repository in multiple sites

I have this content tree:

SiteA
    - Home
    - Articles

SiteB
    - Home
    - News

Repository
    - article1
    - article2
    - article3
    - ...
    - article1000

Is there a way I can pull any article from the Repository Item and display it dynamically on the SiteA/Article Item? Same I would do with SiteB/News.

Additional Question: Is it possible to inherit the layout of each article from the parent Item Repository? The articles will be added via migration(which I would be working on next) it would take too much time reassigning layouts once the items has been migrated.

Upvotes: 0

Views: 528

Answers (3)

Younes
Younes

Reputation: 4823

Looking at your question I can imagine you to eventually choose for an option like introducing Wildcard Items to present the data from your repository on those different locations. there is an interesting module available on the Marketplace.sitecore.net, have a look at that too before deciding what you want to do.

Reading your last line: I can pull any article from Repository/ Item and display it dynamically I would strongly suggest you to go for a wildcard solution.

Upvotes: 3

Holger
Holger

Reputation: 2261

Another option, is to use Sitecore Clones (from Sitecore 6.4) or Proxies (older than Sitecore 6.4).

Clones: http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/10/Sitecore-CMS-6-4-Cloning.aspx

Proxies: http://sdn.sitecore.net/Articles/Administration/Using%20Proxy%20Items%20in%205,-d-,3.aspx Caveat Emptor: Turning on proxies and using them will affect performance. I think it works like this: - each time it has to get items/children it looks in the Proxy table to see if any additional items should be added - the more proxies there are the more "overhead" there will be to each "Sitecore query" has to look though all proxy items to see if there are any additional items that should be included in the result

Though this would copy all the items you choose to clone or proxy and might not be what you are looking to do.

Upvotes: 1

Trayek
Trayek

Reputation: 4410

Yes, there is. There's a couple different things you can do, depending on your requirements.
For instance, you can have a MultilistField on your SiteA/Article item, which enables you to select articles from the Repository item. By setting the Datasource field for the MultilistField to /sitecore/content/Repository you'll be able to select any or all.
However, that's probably not what you want, since you might have thousands of articles looking at your article names.

Another option is creating a sublayout / rendering that reads the latest X articles from the Repository item. With a simple for loop you could then do something like:

var list = new List<Item>();
var repoItem = Sitecore.Context.Database.GetItem("/sitecore/content/Repository");
for (int i = 0; i < 5; i++)
{
    list.Add(repoItem[i]);
}

Which you could set as a DataSource to an asp:Repeater. Of course, you could do it in many different ways (select the number of child items through some lambda expression, use Lucene to get the items if you also want to use keywords etc.).
You can also have the number of items defined somewhere in Sitecore, so it could be different for SiteB/News and SiteA/Article.

Upvotes: 5

Related Questions