2

There are two attributes in the site definition config XML file that I would like to understand better. If your server (Production) has the content management web site set up separately from the content delivery website, what should the database and content settings be for each of those sites? If your server (Development) only has one single website for both content management and content delivery, what should the database and content settings be in that case?

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>
      <site name="MySite"
            database="web"
            content="web" ... />
    </sites>
  </sitecore>
</configuration>
2

The Sitecore config contains the following comments about these two attributes:

<!--
    content: Database containing items to be edited.          
    database: Database containing items to be used for rendering the site.
-->

The content attribute defines the database which contains the items that will be edited from within the CMS interface. The default website entry in the <sites> section of config does not have this attribute set. Only the shell and modules_shell entry have the content attribute set to master.

The database attribute defines the database to use for rendering the site. The default website entry in the <sites> section of config has this set to web.

Note that different site entries may have different values set for the database attribute, for example on the shell site database=core.

For a standard installation, the settings should be as follows for custom site entries:

  • Content Management - database = web, content not set
  • Content Delivery- database = web, content not set

If you have multiple publish targets that different sites could set this to one of the other "web" type databases if different sites need to use different DBs.

Also, if you take a look at /App_Config/Include/LiveMode.config.example then you will see an example that patches the database attribute to use master. This allow you to view the items without requiring publish from master to web.

Why does the content need to be specified

The reason for the content database attribute and requiring this to be set on the shell site is when you are editing items from the Content Editor the site context is shell. The shell site requires the core database for all it's settings and configuration

You may often see code which references context database like so:

Database db = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;

This is commonly used in code when executing in the content editing interface needs to access items in the master database (or whatever is set as content).

There is some more details in this article about Content and Databases.

0

This depends on your CM/CD configuration, if you are using one web database then you can do the following:

  • Your content management (CM) site should use the master database, so in your site definition, you will set database="master".
  • You content delivery server (CD) site should use the web database, so in your site definition you will set database="the web".

In a development environment, you can set the site database to either of them, when set to master you will browse the site using master database content so you will not need to publish content to web database to see the effect in your site.but still it is better to use web.

You can find more information if you look into the following blog post: Sitecore Solution Production Deployment

  • What does the "content" attribute mean then? – ADH Nov 1 '16 at 20:14
0

content is optional, and I believe it defines the place where content should be edited (e.g., master database). I have never found a need to define content explicitly.

database is the location that the site should use for rendering and delivering content. database is typically set to web, unless you have a specialized need such as a staging site.

For a production setup, it would depend on your business need. For instance, you could have a staging publishing target, and a copy of your site definition which points to this database. This would allow for a preview site that ties back into workflow so content authors and approvers can "preview" their changes on a live system. Typically speaking, your content delivery servers should point their database attribute to web.

For local development, I typically set my site definition's database to master to avoid having to publish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.