What is Sitecore Datasource and why should use? - sitecore

I'm new to Sitecore XP 8.2 and try to study by articles and youtube.
However, I can't figure out why we should use datasource, instead of having multiple items in the content tree? How can I enable Global on the content tree?

If you by 'datasource' means 'Rendering Datasource Location' heres a real life example, where using datasource is helpfull, instead of having data items underneath each page item.
Lets say, you have a Footer module, which you would like to include on all content pages in your website. And the Editors should be able to change the content of the footer module on all pages, but the effect should be global.
In this case, could a solution be, to make a folder at the top of your tree structure called 'Shared Modules', and point the 'Footer Rendering Datasource Location' at this folder.
In case an editor changes the footer text on the main page or a subpage, the effect will allways be saved in the same location.
unlike, a 'Texbox module' which you would like to have multiple of on multiple pages. these would you like to have placed underneath each of your content pages in a folder e.g 'Page Modules'.

You can use Sitecore Datasource for a variety of reasons. One of the reasons is to use this instead of context item so that you can refer to another item in Sitecore content tree. Another good reason is to personalize your content or run the A/B testing, content testing. Using Sitecore datasource, make different parts of page componentize and all this helps content editor to improve experience in content editor.
For some good information on using Sitecore datasource, you can look at
https://www.linkedin.com/pulse/how-improve-experience-editor-sitecore-number-ways-rohit-chopra
https://www.linkedin.com/pulse/sitecore-personalize-content-conditional-renderings-sub-rohit-chopra

In short, with datasources you can re-use your items, makes your life much easier if you want to go with personalization and its easier to manage in terms of security/workflows.

A datasource is a pointer from your presentation to a content item. This item can easily be picked from a global or local placement in the content tree. You can still navigate from the datasource to other items (like subitems) if you want a more complex structure for your content.
The advantages of using datasources, is that Sitecores presentation engine, Experience Editor and marketing/personalization is based on the usage of datasources. Further you cater for reuse of content, as multiple presentations can point to the same datasource item.
By using datasources you decouple the content from the structure of your content tree and hierarchy.

Related

Master/Detail Dilema: Wildcard items vs Sitecore Pipeline for Virtual Items or any better idea?

I used to implement listing/detail scenarios using wildcard items, meaning that, for the sake of URL, I create a regular item to display the list and then under that node, I create a wildcard item to represent all possible detail pages, like:
/news/*
(i generate a friendly name by code to replace wildcard and produce the full URL such as: mywebsite.com/news/the-meeting-press-release)
Then I create a folder or a bucket of content items somewhere else as my repository. Then I assign same datasource to listing node and wildcard node to give them same repository of content items.
Main reason I want to do this is to use datasources and make navigational nodes (which generate actual pages and URLs) to be separate from Content folder structure. In other words, separation of concerns: navigational items as presentation nodes and content items as my data repository.
This is an easy way to work around master/detail requirements but I always feel guilty about this, it feels like this technique breaks integrity (sitecore links table on database) and design pattern in Sitecore back-end.
For example when I look at Analytics, I get * as name of items, clearly the it feels like aliens to back-end system.
I know this is not a new topic. I have seen threads like this or ideas like Sitecore Pipeline Processor for Virtual Items to implement such requirements.
Is there any best practice about this? Have anyone good example of what is most sitecore-friendly way to implement such pipeline processor? How do you address this issue with wildcards on Analytics?
I'm going to go a different way to Martin here. I have successfully used Wildcards many times for the exact purpose you are suggesting (For an example have a look at http://www.atpworldtour.com/news - all news articles are items in a bucket with a wildcard to resolve the url).
There are 2 options to enabling the page editor.
The news article item becomes the page. In this way, you need a new processor in the httpRequestBegin pipeline that resolves the url to the item and then sets Sitecore.Context.Item to the current item. IIRC you do this by setting one of the pipeline argument properties. This will work fine in the page editor as the context item - the one being edited - is the news article. And then other renderings on the page can just use data sources as needed.
The news article resolves to a Datasource. I have also tried this method. To do this, you need a custom Datasource resolver. I sill used a processor in the httpRequestBegin pipeline so that I didn't have to resolve the Url multiple times for each rendering that needed the datasource. But then in the RenderRendering pipeline I had a processor that detected if I wanted a wildcard Datasource and used the item that had been resolved in the httpRequestBegin processor.
There are pros & cons for each method.
Option 1 is nice and simple. It means that you could use a single wildcard to resolve different "types" of page item as the presentation is on the page item and not the wildcard item, also each item can have its own custom presentation, so Datasources set in the page editor would be unique to an article. That is also a disadvantage in someways. A/B testing becomes more difficult with main article text etc... You are limited to testing article versions.
Option 2 is more flexible in the testing area - you can easily test/personalize parts of the article by changing the Datasource. But you are more limited as the presentation must be set on the wildcard. So renderings that are not part of the main article will have the same content/settings across all news articles.
I was previously in the same boat as you are. The are few issues with wildcard items, like resolving datasources or disability to run a page in Page(Experience) Editor or nested wildcards. Regardless of that, I have used wildcard few times and they do their job.
I've managed to resolve datasources properly, based on URL (see blog post: Automatically resolving correct Datasources for wildcard items based on URL), still did not sort the rest others.
Update: Richard suggests the way of implementing Page Editor below, you may find this helpful
Thus, my answer would be:
I would recommend you to keep classical approach of having a page item for each news item, rather than using wildcards. Content authors would use habitual approach (and page editor) rather that editing datasources somewhere on the content tree in Content Editor. If you configure that properly with templates and standard values - there would minimal hassle to create new news article.
In case if you worry about potential raise of number of news articles - use Buckets along with it (or suggest manual strategy to group them into folders).

Sitecore 8 implement tooltip on RTE authored content

We have a requirement to implement tooltips for words that are authored in Sitecore RTE.
The idea behind is that user should be able to hover over the word and see it's description/meaning.
Is this possible to achieve in sitecore? Did a quick search on marketplace but could not find any modules.
Below are some options to consider for achieving what you described.
Inject Tooltip HTML in a renderField pipeline
In this option, you would extend the renderField pipeline. First, you will need to ensure that you are dealing with a rich-text field, and if so, locate terms and replace them with the necessary markup that is required for the tooltip. This could be as simple as wrapping the word in an <abbr> or perhaps a <span> element with a CSS class. The list of terms and tooltip content could be sourced from items in Sitecore or a custom Sitecore Dictionary. Caching the terms would be essential as this pipeline processor is invoked frequently every time a field is rendereded.
Progressive enhancement with JavaScript
This approach is almost entirely based on the client-side. Terms could be located and replaced fairly easily with the help of JQuery. If the list of terms is of a reasonable size, they could be bootstrapped into a JavaScript variable. Once terms are located and enhanced, a separate, asynchronous call to a REST endpoint could be made when hovering or clicking the term. The API would accept a term and respond with the term's definition.
HTML Snippet in RTE Editor
Sitecore RTE editor can be extended with additional buttons. One of these options allows you to insert predefined snippets of HTML. The RTE editor also has a setting to specify a CSS file to style the content within the field (<setting name="WebStylesheet" value="/css/yourstylesheet.css" />). Styling would be necessary in order to target the description markup and make it visible to be edited, whereas, on the public site, the description markup would normally be hidden by default until the term is clicked on or hovered over.
Dynamic Link Replacement
http://www.layerworks.com/blog/sitecore-token-replacement

Where to create the Articles in Sitecore?

I'm trying to understand the best approach to create article items in my sitecore 7.2 project.
Basically I'm considering 2 options:
1 - Create an article as a page;
2 - Create an article as a Site Data Item.
1 - Create article pages under a given page (i.e. My Articles). This way each article would have a specific URL out of the box, easier to understand in Content Authors' point of view;
2 - Have a specific folder (i.e. Article Folder) under Site Data. This way we don't need to have a page for each article - I was thinking to have a single Article page that would render the article fields. However this would require more work in terms of URLs, navigation, etc.
Is there any other ideas? Am I missing something? I was also having a look at Buckets...
Thank you
I'm going to disagree with Marek and recommend you opt for option 2.
Storing your articles in folder under a Data node allows those items to be datasourced. This is the principle Sitecore was built on. You can then surface those articles in a number of interesting ways via Widgets such as Promo Panels, prompting the user to click through to read about the article without duplicating its data and requiring Content Editors to manage data multiple times.
It even supports multiple sites, so the Articles can be used in other sites you may add to your Sitecore instance in the future.
As you state it will require extra work in terms of Urls and Navigation but it can be achieved via Sitecore's Wild Card Item and you an even use a great open sourced Module from Sitecore's Marketplace to complete 90% of the work for you. See links below for more information.
You can still implement Marek's point of applying Presentation Details once on the Standard Values of the Wild Cart Item you create. If you are using Sitecore 7 and above you can store all your articles in a Bucket so if you have lots of articles they are stored and searchable in a meaningful way.
http://www.sitecore.net/learn/blogs/technical-blogs/getting-to-know-sitecore/posts/2011/09/wildcards-and-data-driven-urls.aspx
https://marketplace.sitecore.net/en/Modules/Wildcard_module.aspx
In a standard one instance setup the easiest implementation is to create articles as pages.
In Sitecore you want to limit the items in a folder to 100 or less which is best practice to keep the content editors experience optimal.
This then leads you needing a folder structure and a couple options:
Manually maintain a folder structure for your articles. For example articles/year/month/day. This gives your editors the most control over the folder structure and allow them to navigate the articles in a more traditional way via a visible folder structure.
Use a bucket which automatically generates the folder structure and hides this complexity from the content editor. This takes the manual folder creation and maintenance away from the content editor and are automatically generated based on the configuration you set out for your bucket. The folders wont be visible to the content editor so they will be forced to search in the bucket for any articles rather then navigate the folders.
Use the shared source News mover module (https://marketplace.sitecore.net/en/Modules/News_mover.aspx). This takes a different approach to the above. It works via a traditional folder structure however it generates folders and moves the item on save based on the date field in the article. So the news mover handles the generation of folders however you will still need to check your not exceeding 100 items per folder again for performance when opening folders with large amounts of items.
With all solutions you must still consider the URLs for your articles as they will include the folder structure by default. This is not always acceptable. I prefer to remove the folder structure from the URL. For this you need to create a custom linkProvider and a custom HttpRequestProcessor. Firstly the linkprovider allows you to ensure the new URL is always created and displayed in your site as you want. Next the HttpRequestProcessor ensures that when navigating to the shortened URL Sitecore recognises it as a valid URL and presents the correct page.
By excluding the folder structure from the URL it also adds the additional benefit that the URL is not dependent on the structure. This means editors can change that folder structure and not need to create redirect items to ensure SEO rankings or users bookmarks are not lost.
The cleaner data model is to use the wildcard approach for the URLs and centralize the storage of articles data in a bucket of datasources. This will give you optimum performance and reuse of the data.
However, this isn't how an author thinks about their website. When they use the system, they tend to navigate to the area where they would view articles and try to create a new one there. Authors tend to think in 'pages', so try to hide whatever data model you are using from them and give them the ability to edit the page with Experience Editor.
Some developers try to optimize too far and forget that the authoring experience is likely the most important piece of the delivered solution. The author doesn't care how efficiently you stored the data, only that they can edit it easily and publish efficiently. Whatever model supports that for your author base is how you should implement it.
My recommendation is a page-based approach where the author creates the URL structure with folders and items, something they understand. Then, if you really need to, you can have the primary article data be a datasource-driven component on the page. The user gets to use all the tools they are familiar with (Experience Editor,preview navigation) but you can still store the raw data in a centralized folder. You could then theoretically swap out the article data using DMS rules, or hide information based on authentication or membership status.
Go with approach 1: article is a page.
Define all your presentation details on Article Page template __Standard Values. All new articles will get them. And you can change some of the presentation details for your chosen articles if you want.
If you know that you'll have lot of articles, think about year/month/day folder structure, e.g. articles/2015/06/12.
Approach 2 doesn't give you anything - you still need to have an item for every article. And as you wrote, it would require additional coding which is not required.

Sitecore page components aren't versioned with page

For a website we're working on, we had a pretty complex design to support. So, we chose the strategy where all content on each page is made up of components. Authors can insert various components such as a heading, rich text block, images, etc, allowing them flexibility in laying out pages. This was the only away we could support the complex design that was created.
This set up is working well except when it comes to versioning and search. When pages are versioned, the components on the page are not. When items are indexed for search, the components on the pages are not being indexed as part of the page. We think we may be able to solve the search issue with a custom search index, but the versioning issue seems much more complex.
Has anyone else faced these issues or have thoughts on solutions? We're on Sitecore 7.5.
A simple answer would be to upgrade to version 8 as soon as its released as version 8 will add versioning to the renderings field.
My Guess is that you are setting the content of the fields on the rendering parameters of each item? If that is the case I would suggest taking a slightly different approach. Use DataSources. You could have a few templates that hold the data, e.g. RichTextTemplate, SingleLineTextTemplate, ImageTemplate - all with a single field in, then when you add a heading or rich text block to the page, setup the rendering to all the editor to create the data source.
This way all the content can be versioned properly and you are still separating your content and presentation.
To keep the tree un-cluttered, we use an "Assets" folder under the item for all content:
Example Tree:
Sitecore
Content
Home
Assets
Page 1
Assets
Heading
Rich Text Block
Page 2
Assets
Heading
Rich Text Block
Image Block
etc...
The search problem sounds similar to this post: How to index sub-content in Sitecore with Lucene?
That suggests a computed field. In your computed field, check that your template is a page and then get all the renderings for that page. Once you have those, get the renderings DataSource items and you can build a big search field using the content from the DataSource item's fields.
This would save having an extra index with a custom access layer. It all stays within the Sitecore API.

Flexible block positioning in Django?

In Drupal you could choose in which "region" of your site you want your block displayed. You did not have to modify any php/html code in order to achieve this.
Can such a thing be achieved with Django, and if yes, how?
By block I understand a piece of html output that doesn't have it's own URL and gets displayed along side the main data. (for example a search box or a poll)
Hm you probably want to create context processor and just output from it where you want it in template?
If you want reordering of content blocks in html output inside admin then you need something to generate that output like cms. You could try something like django-fluent-contents for this without requiring big cms.
Django and Drupal shouldn't be compared like this: Drupal is a CMS, Django is a web framework.
If you want to get a somewhat similar experience, I would look at using django-cms. With this, you can create numerous templates and set placeholders within these templates (these are regions of the page like 'sidebar', 'footer', 'content area' etc.). When you go to create a new page in django-cms, you select which template you want to use (maybe a two column layout or a three column layout with a header - depending on what you have created) and then you choose what content (or plugins) you want to place within the placeholders you have created in the template. So this is a somewhat similar experience to Drupal's regions.