Tuesday, July 29, 2014

Sitecore - Has an item been published

How to keep track of what Sitecore items have been published

I recently got this question from a colleague who was looking into a customer reported issue.
He was wondering if he could see if this specific page/item has already been published.

The default answer here would be to check the "Web" db or any other publishing target. However, this is a tedious task when checking multiple pages as well as when these pages are nested deeply within your root structure.

So I decided to see what the web had to offer with regards to this.

I first found a Sitecore answer that gave a list of the Items that were in the publish queue. This provides insight into what has NOT been published yet. But does not show what HAS been published:

http://sdn.sitecore.net/Forum/ShowPost.aspx?postid=26498

This was however not what I needed, an I continued on...
The solution come from Stack Exchange:
http://stackoverflow.com/questions/15172346/sitecore-flag-new-items-as-unpublished-items

Turns out Ruud Van Falier wrote a nifty and obvious piece of code to display the publishing status on the gutter...


Check it out !


Sitecore Hidden Gems: Virtual Site setup

Multi-Site setup with Sitecore

Sitecore is in my opinion one of the easiest CMS's out there to facilitate a multi-site setup. It offers a number of approaches to doing so. You can either create entirely different structures and implement it as such so that through security and configuration entire different structures can be disclosed while at the same time specific content can still be shared in one location.

But you can just as easily decide that a specific node within your website should function as a seperate site with its own visualisation and behavior.

For example, you might want the following structure within Sitecore :
"Corporate Home > Tertiary pages > B2B > Support" to be disclosed under the following url:

http://www.corporate.com/support/

In order to do so I tend to revert to the Virutal Site setup that is available within Sitecore

How-To

Siteore configures its mapping of the various path, hostnames, databases and so on through the SiteDefinition.config file. Found under "App_config > Include"

The entries defining the sites look like this:


As you can see, both the virtualFolder and the physicalFolder are set to the root "/".
The Sitedefinition file contains multiple entries in a multi-site setup, one for each configured website.
Sitecore resolves the site definitions sequentually, meaning that more specific configurations have to be placed on top and more generalistic ones go to the bottom !

In the description of all configuration properties, the virtualFolder is described as followed:
"The prefix to match for incoming URL's. This value will be removed from the URL and the remainder will be treated as the item path."

By setting BOTH (!) the virtualFolder and the physicalFolder to the required path you can disclose the required structure and site: virtualFolder="/Home/TertiaryPage/B2B/Support"

If this change is not done on both the virtualFolder and physicalFolder, Sitecore tends to give an error on all sites (this is a general configuration file):



Pitfalls and other options ?

There are a number of things that you do have to keep in mind when choosing for the solution through a virtual folder...

Location of language parameter in the url

Sitecore has the habit of making you used to the following url structure:
http://www.corporate.com/en/some-kind-of-page/

So the first part (up to the language "/en") is the actual base url followed by the last part which is your navigation path within the site.

However, when using the virtual site setup you will have the following:
http://www.corporate.com/en/support/some-kind-of-support-page/

where you might be expecting (for logic reading and SEO purposes) :
http://www.corporate.com/support/en/some-kind-of-support-page/

After requesting this with Sitecore it does not yet appear to be possible at this point to do this via configuration. Custom code might make this work but I do not have this available.

Link resolving with Sitecore

Make sure you do extensive testing when you have an extreme case of custom link provider implementations and cross site linking to make sure that the virtual site setup does not break any functionality. Some tweaks to the link provider should take care of possible issues, if any.

Alternative solution

If the above solution is not possible, too complicated in your current setup or the site that is to be disclosed has its content fragmented across different nodes you can use a reverse proxy setup within IIS to get you on your way. Do keep in mind that this requires a lot of IT configuration, handling of specific cases (media, cross-linking) and so on.