Experience Sitecore ! | More than 200 articles about the best DXP by Martin Miles

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

Sitecore xDB Cloud: don't want to mess with xDB? Let Sitecore do that for you!

Just wanted to share one option I recently found out, not many people aware about.

To start with, I am working in a large insurance organisation (which is in much regulated industry) with a pretty complex configuration of load balances, reverse proxies, multiple geographically distributed CD boxes in different data centers (and networks). So I was very surprised to find out there is such an offer from the vendor.

Sitecore offers to host you xDB in their cloud, powered by Azure. All maintenance and processing raw data from Mongo to Reporting database is done on their side. What is ends up for organisation is just setting connection string (to reporting database) in config and ensure firewall rules allow connectivity to the instance.

Pricing seems to be bespoke for your solution and not cheap (as everything from Sitecore), but it is reasonable if compare to a full time resource efforts, for example it comes out that our company even saves a bit! Again, this may not fit to all organisations and depends on people and infrastructure they already have in possession.

This information is a very "early bird" for me, so I will update with more details as soon as we start working with Sitecore xDB Cloud

IIS URL Rewrite module - as reverse proxy with links rewrite

Not many people know that IIS itself can serve as Reverse Proxy, with rewriting URLs on-the-fly. We are going to take a look on how to configure that feature. Let's assume we have 2 websites - primary website that has URL http://test2/ and is a hosted by IIS, moreover there is an instance of Sitecore installed; and another external static website that has URL http://external/ and it has few static pages and resources. For this experiment I got external website hosted at the same IIS instance, while in reality it can be literary anything and anywhere.


Apart from having IIS, you will need the following prerequisite:

- URL Rewrite Module installed, version 2.0

- Application Request Routing version 2.0


The easiest way to get all the prerequisites is to install them through Web Platform Installer. It will install all of them so you'll just need to have IIS refreshed and get ready to start.



External website contains static.html file with the following code

<div>
    img/sitecore.png<br>
    <img src="img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<div>
    /img/sitecore.png<br>
    <img src="/img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<div>
    http://external/img/sitecore.png<br>
    <img src="http://external/img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<p>
    <a href="sitecore.zip">sitecore.zip</a><br>
    <a href="/sitecore.zip">/sitecore.zip</a><br>
    <a href="http://external/sitecore.zip">http://external/sitecore.zip</a><br>
</p>

This code has 3 images and 3 links to an archive file, each of them is either relative link (from the doc level, for sure) or absolute link (from web root) or fully qualified link including domain name and protocol. This HTML renders renders into the following screenshot:


Our objective is to have a "virtual" "folder" called ext on the test2 website so that it "mapped" to external website and also correctly "maps" and rewrites all the resources of external website on resulting page.

Example:

When we hit http://test2/ in browser - we get default Sitecore page as it is provided by Test2 website, as normally.

When we hit http://test/ext/static.html - we get the page at that URL but with the content of external/static.html page with all links and references rewritten to be test2/ext/*.* instead of external/*.*

So, to make IIS Rewrite work as reverse Proxy, let's do the following steps:


Make sure "Enable proxy"is checked, otherwise nothing will work.


In URL Rewrite section, click "Add Rule(s)" link, then from popup screen select "Reverse Proxy" and specify the rule. Also check outbound rules as the are rules that factually rewrite internal links. Please note that this function may add some overhead to your website performance.


After you specify the rules - one inbound and 2 outbound (they are shown below) - reverse proxy now functions and you may verify that by requesting the following ULR (as on the screenshot below):


Notice, that all links and images look correct, as the were before. To ensure they were rewritten correctly, let's view the source file of resulting page. Here is it:

<div>
    img/sitecore.png<br>
    <img src="img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<div>
    /img/sitecore.png<br>
    <img src="http://test2/ext/img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<div>
    http://external/img/sitecore.png<br>
    <img src="http://test2/ext/img/sitecore.png" alt="sitecore" width="230" height="106">
</div>
<p>
    <a href="sitecore.zip">sitecore.zip</a><br>
    <a href="http://test2/ext/sitecore.zip">/sitecore.zip</a><br>
    <a href="http://test2/ext/sitecore.zip">http://external/sitecore.zip</a><br>
</p>

As there were no need to rewrite relative URLs - they remain untouched. However root-folder URL and full URL were rewritten to satisfy new domain name and desired folder-path.

And finally, here is resulting configuration that makes it all work. Whatever we have previously configured is stored in the configuration file within system.webserver node in rewrite section:

<rewrite>
      <rules>
        <clear></clear>
          <rule name="ReverseProxyInboundRule2" stopprocessing="true">
            <match url="(ext)/(.*)?"></match>  
              <conditions>
                  <add input="{CACHE_URL}" pattern="^(https?)://"></add>
              </conditions>
              <action type="Rewrite" url="{C:1}://external/{R:2}"></action>
          </rule>
      </rules>
      <outboundrules>
        <rule name="ReverseProxyOutboundRule2" precondition="ResponseIsHtml1">
          <match filterbytags="A, Form, Img" pattern="^/(.*)" negate="false"></match>
          <action type="Rewrite" value="http://test2/ext/{R:1}"></action>
        </rule>
        <rule name="ReverseProxyOutboundRule1" precondition="ResponseIsHtml1">
          <match filterbytags="A, Form, Img" pattern="^http://external/(.*)?" negate="false"></match>
          <action type="Rewrite" value="http://test2/ext/{R:1}"></action>
        </rule>
        <preconditions>
              <precondition name="ResponseIsHtml1">
                  <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html"></add>
              </precondition>
          </preconditions>
      </outboundrules>
    </rewrite>

There is no need to use visual configurer at all, you may just drop this snippet on web.config into appropriate section and it will start working straight away!


Sitecore 8: re-indexing errors out and module installation never ends without MongoDB running

What is happening? we got a commonly met point of frustration since recent - imagine, you have just installed an instance of Sitecore 8 and are trying to install some useful modules, for example Web Forms for Marketers 8.0 or PowerShell Module. And all you get is never-ending progress box dialog.


However that occurs not only while installing a module, but also when trying to rebuild indexes via built-in Developer toolbar interface. Same story, but at least this time it tries to tell us something with View all messages section, unfortunately unsuccessfully - there are no any error messages seen once you expand this box.



Why is it happening? Going through log files made me thinking there is something with xDB, it looks like sitecore tries to perform write operation into Mongo, but is not able to do. And because Sitecore 8 is now using modern client-based SPEAK interface instead of outdated SheerUI, the back-end where in fact an error occurs is not able to notify client about that (I believe is it not yet implemented and would be fixed with future updates).

How to fix? Let's install and run MondoDB. After default windows installation, the easiest way of running Mongo would be just running its server with dbpath parameter to where DB placed. I say the easiest because there is a better alternative to run MongoDB as Windows service application, so that it will run on system start up.


So, as soon Mongo is up and running, let's test our assumption and try to re-build Lucene indexes again:


And bingo! It now works well! Hope this solution helps.

Sitecore extensions for Google Chrome review

  1. Sitecore Developer Tool
  2. Sitecore Analytics Testing Tools
  3. Sitecore Expand Collapse Sections
  4. Sitecore Keyboard Shortcuts
  5. Sitecore Helper
  6. Dan's Sitecore Shortcuts

1. Sitecore Developer Tool

This is a nice, elegant and non-obtrusive shortcut extension located at the top right of your Chrome browser. It has several most useful shortcuts logically grouped by tabs.


Admin Pages tab contains useful admin pages hotlinks.


Database tab allows to quickly change context database.


Mode tab has 6 switchers - the names are self-describing.


There is also options tab, where you can add / edit favourites, add more databases and perform other settings for the extension.

You may install Sitecore Developer Tool by this link.



2. Sitecore Analytics testing tools

As it comes clear from its name, this is an extension to fit specific analytics purrposes, which are: clearning analytics-related cookies and specifying a forwarded IP address for GeoIP lookups.


Below there are screenshots of its settings screen:





Download and install exension: the link.



3. Sitecore Expand Collapse Sections

Minimal extension that serves just one purpose - expand and collapse data section panels in Sitecore.


What can be easier?


Unfortunately, at the moment this extension does not support Sitecore 8, so the last funcional verison is 7.5

You may install Sitecore Expand Collapse Sections by this link.



4. Sitecore Keyboard Shortcuts

It presents


It is a powerfull extension that allows you to create hot keys to quickly complete common tasks in Sitecore. This is especially useful for demos or for quick access to frequently used items. No need to repeatedly expand the content tree any longer.

it works well for Sitecore 8 as well as with all previous versions I have tested with. It also works well on Mac computers, however mac-specific keyboard extensions (ie. Cmd) are not supported. screenshot below shows settings screen:


And here is a dropdown containing list of possible actions. Quite impressive!


Download and install exension: the link.



5. Sitecore Helper

This extension brings upgrades the Sitecore interface with toggleable usability fixes.Applies several fixes & updates to the Sitecore user interface, use the options menu to toggle them on / off.


Download and install exension: the link.




6. Dan's Sitecore shortcuts

Extension provides a drop down with features and shotcut buttons.


Download and install: the link.


Hope these extensions may help you to improve your productivity while working on Stecore projects!

Know your tools: SIM - Sitecore Instance Manager

Sitecore Instance Manager (SIM) - the must-have tool for all Sitecore professionals and platform enthusiasts. It is a "Swiss army knife" for all types of activities related to installation and configuring Sitecore instances. So, what it does?

As it is obvious from its title, SIM simplifies installation of Sitecore, minimizing it to just few very intuitive clicks. SIM supports all versions of Sitecore, developers work tightly with platform vendor, so since recent they tend to synchronize SIM updates with new Sitecore releases. Oh, nearly forgot to mention, SIM has auto-update module that can update the program silently in background, or with a prompt, or just leave user alone once he prefers getting updates donу manually.

Here is the main screen of Sitecore Instance Manager:


You have all available instances listed, you can install new or remove existing, do some configuration changes and much more. SIM operates "web-folder" installation archives as they came form Sitecore, one can download zip and manually place it into specific folder (that is configurable in program settings) or can download and store any platform version directly from SDN. In that case he/she might need to type in SDN credentials and pick up exact Sitecore version from options drop-down. As soon as zip is downloaded, it can be installed.

The installation process occurs in few clicks and is show on several screenshots below. First of all, we select which version we are going to install from the list of stored in local repository. Also there are fields to specify instance name, hostname and the installation folder.


The program accurately installs files, restores database and sets appropriate SQL permissions, configures Application Pool and create config files with correct values.

SIM is great in that it allows not just install Sitecore itself, but also you may specify which modules you would like to install straight away, just by simply checking them from the list of available.



Apart from modules you may also install certain custom packages, likewise you may have a fully working website - both items and file system substructure packed within a package, so it may become available straight after the installation. As another example, I always install useful Sitecore adjustments with SIM in order to benefit out of them straight away.



Not only custom packages can be auto-installed, but also such called configuration presets. These are certain configuration patches, each addressing small but important setting, will be placed into App_Config/Include folder.



The installation itself does not take much time. Sitecore 8 takes approximately 1 minute in virtual machine on my MacBookPro. Significantly faster comparing with time spent on default installer.




SIM also have multiple useful shortcuts at one place, like links to important Sitecore folders, configuration tools, hosts editor, IIS recycle an many many more.




I would award SIM with the highest rate and highly advise to download and play with it, even if you do not regularly play with installation and instances.

Download: SIM on Sitecore Marketplace


Fixing unfriendly default Sitecore 8 styles from huge elements, padding, spacings and few more improvements (package)

I am entirely happy with Sitecore 8.0 improvements, except one simple, but quite important thing - new look and feel megalomania. In first place by saying that I mean the way how Sitecore with new Metro-like interface manages space and huge paddings between elements. The maximal impact you may experience when working with Content Editor - content tree and item fields. I got an assumption that it was designed for use on as little as 27" monitors, not less. If you are running Sitecore from a 13-15 inches laptop - you definitely should read this blog post to the end.

Things however are not as bad and the good news is - it can be relatively easy to improve by simply editing CSS files, that Sitecore utilizes - they are located within <web_root>\sitecore\shell\Themes\Standard\Default folder. The bad news is that the folder contains 34 CSS files and some of them have several thousands lines.

So, my dear reader, I have made this dirty job for you and you may download the package that modifies styles, which make spaces as compact as they were in previous versions.


To start with, compare 2 images below. First one shows how Sitecore 8 looks originally, straight after the installation:


And below there is a screenshot of the same screen after applying a Style Adjustments patch. See how content tree became more informative:



There is one small, but quite handy improvement - we all know database selection tool in the right bottom corner. If you click it and enable "Show Database Name"option - by default you'll get a database name, written on a desktop right above this database selector. But it is displayed only when you see clear desktop, as soon as you open Content Editor - this useful label will be hidden underneath the window. So I decided to relocate this label to the bottom bar immediately left from select box. So now you are aware of current database regardless of wether you have a windows open full-size. Here is a screenshot of how it looks like:



There are still other changes across the whole sitecore - windows, popups, dialogs etc. that were improved. Package creation dialog became more compact as the result:


Screenshot below shows the comparison how it was before. In the default view only 2 selected items are able to fit .... eh-h..



Download the package: so, to get this presentation changes on your environment, please download and install the package: Sitecore 8.0 Style Adjustments-1.2.zip or Sitecore 8.1 Style Adjustments-1.2.zip - agree to overwrite all, when prompted.

Want to revert changes back as it was before? (suprised one would want but still) - apply anti-package: Sitecore 8.0 Style Adjustments-1.2-ANTI-PACKAGE.zip or Sitecore 8.1 Style Adjustments-1.2-ANTI-PACKAGE.zip

Compatibility tested: Sitecore 8.0 - Update 4-5 (however supposes to work on all previous 8.0 releases).

Important! After package installation not all style may work - so please update your broser cache


If you like the updated look and feel, please let me know - I will be pleased to know someone else is using this adjustments.

Cheers!





Software every good Sitecore developer should be aware of

Got your top-spec developer's machine with Visual Studio installed, an instance of SQL Server with databases and Sitecore running on your IIS? So far, so good. You may now start working with platform. However, for real productivity you may need certain extras we'll now go through.

  1. Sitecore Rocks
  2. Team Development for Sitecore
  3. Reflector
  4. dotPeek
  5. Sitecore Instance Manager
  6. Luke
  7. RoboMongo

1. Sitecore Rocks
Today Rocks became a mature plugin allowing unbelievably wide range of Sitecore tasks and activities right from your Visual Studio. It grew from an idea of being able to manipulate Sitecore tree right from Solution Explorer (without permanent switches to browser and back), but with time acquired a mass of killing features, covering all aspects of working with Sitecore. Let's just name few of them:

  • navigate Sitecore tree within VS, create and edit items, layouts, renderings, templates (and their hierarchy), standard values, and also manage Media Library
  • built query analyzer (that was removed from 7.5 into a SPEAK component) that allows to operate all types of queries
  • troubleshooting features addressing tracing and debugging as well as log manager
  • view scheduled jobs
  • all about publishing
  • administration functions to perform maintenance for database, indexes etc; view resulting (after patches) web.config file
  • ability to read Lucene indexes, navigate documents and see field values, terms etc.
  • perform real-time search and replace globally from Query Analyzer
  • view history table
  • everything about creating and managing packages
  • create pipelines
  • all about caching
  • plugin repository to extend functionality further more by applying multiple plugins
Impressive list? But how to manage such wide functionality and not get lost?
Luckily, there is handy Commandy feature that allows you quickly search and access all the features just by a hotkey!

Links:
Sitecore Rocks on Visual Studio Gallery
Documentation page
28 days with Sitecore Rocks technical blog



2. Team Development for Sitecore - TDS
Another Visual Studio extension worth of several separate articles. It is manly focused on resolving troubles of having sitecore itens and sitecore code seperately, so it solves the issue by serializing items and keeping them in source control along with the code so that multiple people working at the same solution can have solid commits and fair versioning policy.

TDS can help you with many other handy tasks like item merging, code generation, packaging and auto deployment, config transformation and others. If you follow the link below - you'll get ver y self-descriptive home page explaining what exactly and how TDS does.

Links:
TDS download page


3. Reflector
Not Sitecore specific, but .NET-wide, Reflector is a tool that decompiles and reveals the code hidden in DLL libraries (if not obfuscated) and allows browse it and drill into system DLLs as well. We use it widely with Sitecore as Sitecore is not allways specific about ints internal architecture in official documentation, but knowing internals is the must for any good developer. A good example can be pipelines architecture - it is not quite documented (if at all) while from time to time one would need to override default behavior or add additional processors. Without knowing what exactly original code does that becomes not possible.

Links:
Reflector download page


4. dotPeek
One more .NET decompiler (which is free, unlike previously mentioned Reflector) have recently joined the market. Apart from doing decompiling job, it has several useful features, like ability to generate PDB files out of DLL, that makes possible debugging of external DLLs in Visual Studio.

  • Exporting decompiled code to Visual Studio projects
  • Support downloading code from source servers or PDB files generation
  • Quick jump to a type, assembly, symbol or type member
  • Effortless navigation to symbol declarations, implementations, derived and base symbols, and more
  • Accurate search for symbol usages with advanced presentation of search results
  • Overview of inheritance chains
  • Syntax highlighting and complete keyboard support
Please read another blog post Debugging and Inspecting Sitecore Libraries to how you can easily do that with dotPeek.
Links:
dotPeek official home page

5. Sitecore Instance Manager - SIM
I have a separate article about SIM, so please read that if you are not yet familiar with this brilliant tool. If briefly, SIM simplifies and automates a process of installing an instance of Sitecore (any version you may have in your local repo) to just few clicks, automatically sets up database and configs, installs additional packages and modules on top of instance and keeps multiple useful housekeeping links (to hosts, configs, iis, database etc.) in one place.

Links:
Sitecore Instance manager on Sitecore Marketplace
My previous article about Sitecore Instance Manager in this blog


6. Luke
Luke.NET is a tool to browse Lucene indexes, see the documents, fields and terms, try writing queries against index and see index physical structure. This functionality is partly covered with Rocks, as described above.


Links:
Luke page on CodePlex


7. RoboMongo
For everyone who is after Sitecore 7.5 (and later) and is working with xDB, Robomongo may seem quite handy. What is does is allows to see what you have in your Mongo instance. RoboMongo embeds the same JavaScript engine that powers MongoDB's mongo shell. It means that you can reuse your existing skills of MongoDB shell in RoboMongo. It provides you with syntax highlighting, auto-completion, different view modes (text, tree, custom), and more.There will be a separate article about it coming shortly.


Links:
Official page

IIS URL Rewrite module - few SEO tricks



1. Canonicals - do 301 permanent redirect (this also works with HTTPS).






    

  


2. Rewrite URL lowercase - one more rewrite rule aiming SEO improvement.






3. Append trailing slash - this is another SEO (sometimes arguable) improvement. It is believed that having trailing slash on your URLs (except when it deals with file names for sure) will improve search engines ranking.










4. Query string rewrite - the example of extracting query string parameters and rewriting it in your own manner






    



5. Redirect to HTTPS - forcely redirect all non-secure request to HTTPS









6. Prevent image hot-linking - disallow strangers of reusing images hosted on your website in order to protect them and traffic.










The quickest acceess to Layout Details dialog of Presentaion Details

This post going to be a quicke one. One of the most frequent screens I have to deal with in Sitecore is Layout Details dialog of Presentation Details:


I thought once, why not just to have the link to it from item's Context Menu? Sounds good, but, foirst of all, what is context menu?

Context Menu is just a set of Sitecore items under /sitecore/content/Applications/Content Editor/Context Menues/Default folder within core database. Each child item (except dividers) is derived from Menu Item template. The most interesting field there is Message - its value stores is nothing but just a Sitecore command with a parameter of current item (as all that happens in item's context).


Just want to remind - Sitecore commands are defined at <web_root>\App_config\Commands.config file, you may freely use any of them that start with item: (but not limited to that).

So, the only thing we need to do is to create an item under /sitecore/content/Applications/Content Editor/Context Menues/Default folder, and set its message to item:setlayoutdetails and that's it. Also you may configure Display name and the Icon to be shown next to that label within context menu (something like Applications/32x32/document_gear.png)


As soon as you return to master database, you'll get new context menu shortcut working:


This trick works on all versions of Sitecore. For lazy guys - here's a package for download that will do exactly the same - create Set presentation item for you within core database.

Hope this helps!


Debugging and inspecting Sitecore libraries

Debugging requires symbol files to present within a bin directory along. You have Sitecore libraries, and they are not obfuscated, so you may decompile and inspect the original code using various tools like Reflector. But you need PDBs to be able to to debug those libraries, for example perform step Into, watch and modify locals, set breakpoints and similar actions.

How to generate PDB files from assembly? There is a great (and free!) tool from JetBrains called dotPeek. As soon as you download and install it, you will be able to generate PDB from any non-obfuscated assembly with it. To do that, first specify the location where PDB are kept:


Also allow to debug "not just my" code -this will allow debugger to step into methods that are stored in other referenced libraries, of course of you have their PDBs in symbols folder, as set on previous step.


Now with dotPeek we'll generate PDB under the same path previously set in Visual Studio where it will seek for symbols. Open library in dotPeek, right click its context menu and select Generate PDB, as on a screenshot below:


Remember path should be the same:


Congratulations! Now you can debug that DLL and get more understanding of how Sitecore works internally especially when sometimes you may need to override its functionally and implement your custom logic based on that.

Important! On the recent versions of Sitecore, especially Sitecore 9 or newer you may experience troubles with stepping in withing Sitecore.Kernel library. That happens due to that with time it has been more and more rewritten to rely on Sitecore.Abstractions so you will need to generate PDBs and de-optimize that one as well.

You are now able to debug the code, step into the functions and investigate the logic as the code runs. But you may not still get the entire experience as if you were debugging your own code - due to optimization. To overcome optimization you need to start Visual Studio as Administrator with setting a specific environment variable:
set COMPLUS_ZapDisable=1
cd /d "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE"
start devenv.exe
exit
Next, for each DLL you are about to explicitly disable optimisation, you need to accompany with a *.ini file having the same name and the following instructions (example for Sitecore.Kernel.ini):
[.NET Framework Debugging Control] 
GenerateTrackingInfo=1 
AllowOptimize=0
Finally, as ReSharper is your permanent friend, you'll find the most convenient way to inspect the code by using its Assembly Explorer:

Hope this helps!