Monday, August 22, 2016

Rich Text Editor Drop-down Classes in Sitecore 8

The Rich Text Editor in Sitecore is remarkably flexible in terms of customising to make life easier for our editors. Part of this is adding classes to the Apply CSS Class drop-down, here you can define classes to match your corporate branding and hopefully reduce the temptation for editors to go mad in the HTML tab, (or even allowing you hide the HTML tab entirely (core database - security permissions)). 


This blog was inspired by sifting through several posts to find out how adding these classes is different in Sitecore 8 > 

 The community of course is always a good starting place and this post does in the end provide the answer. 

https://community.sitecore.net/developers/f/8/t/2114

I did however think it deserved a simple summary so here we go. 


Steps 

The old way

  1. Add you classes to your main CSS, these days we mostly include a SCSS (SASS) file as compiled CSS is modular and much easier to work with than on huge file
  2. Add you CSS to your editor file, this file is used to display your edits in the RTE editor window and keeping it in sync with your front end CSS help avoiding editor confusion 

How this editor file is defined and included will differ depending on your solution. 

The default Sitecore install uses a web.config setting:

 <setting name="WebStylesheet" value="/css/yourstylesheet.css" />

Note: I'm writing this based on a Habitat solution so with everything Habitat the web.config is broken out in many separate .config files. The base solution includes a theming.config shown below: 

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
    <pipelines>
      <mvc.getPageRendering>
        <processor type="Sitecore.Foundation.Assets.Pipelines.GetPageRendering.AddAssets, Sitecore.Foundation.Assets">
          <defaultAssets hint="raw:AddAsset">
            <asset type="Css" file="/assets/plugins/font-awesome/css/font-awesome.min.css" />
            <asset type="Css" file="/assets/plugins/simple-line-icons/simple-line-icons.min.css" />
            <asset type="Css" file="/assets/plugins/animate/animate.min.css" />
            <asset type="Css" file="/assets/SX.Sitecore.Theming.css" />
            <asset type="Css" file="/assets/SX.Omnes.Font.Dev.Environment.css" />

            <asset type="JavaScript" file="/Scripts/jquery-2.1.4.min.js" location="Head" />
            <asset type="JavaScript" file="/Scripts/jquery-ui.min.js" location="Head" />
            <asset type="JavaScript" file="/scripts/bootstrap3-typeahead.min.js" location="Head" />
            <asset type="JavaScript" file="https://use.typekit.com/ord5ubi.js" location="Head" />
            <asset type="JavaScript" file="/javascripts/bootstrap.min.js" location="Body" />
            <asset type="JavaScript" file="/scripts/SX.Sitecore.Theming.js" location="body" />
          </defaultAssets>
        </processor>
      </mvc.getPageRendering>
    </pipelines>
    <settings>
      <setting name="WebStylesheet" value="/assets/SX.Sitecore.Theming.Editor.css" />
      <setting name="WFM.EnableBootstrapCssRendering" >
        <patch:attribute name="value" value="false" />
      </setting>
    </settings>
  </sitecore>
</configuration> 

The style-sheet that is defined there will be used to populate the drop-down and used in the RTE. The gotcha with this is that everything in this style-sheet will be shown in the drop-down, using the class name which are often not descriptive or understandable. Things like anchor attributes will also be shown which is just messy and confusing for editors. 

The better solution is used in Sitecore 8 and uses 3 files 

The new way 

  • yourMain.css
  • yourEditor.css
  • ToolsFile.xml 

ToolsFile.xml is found here: 

\inetpub\wwwroot\sitecore\Website\sitecore\shell\Controls\Rich Text Editor\ToolsFile.xml

This xml file defines the tools in the RTE and one of the nodes is <classes> which defines the classes in the drop-down. Here you can define a friendly name for your classes and point it to the corresponding CSS class using the value attribute. 

i.e. <class name="Green Button" value=".green-button" />

Get these three ducks in a row and your good to go. 

Don't forget to clear your cache after making changes, some browsers may be reluctant to show your changes.   

As an aside the ToolsFile.xml also allows you to define the HTML snippets and custom links in the RTE, again useful for making the job easier for your editors and avoid them pushing presentation language tasks back to the dev team.  

Hope this is useful for someone. 

UPDATE

The order that the classes are shown in the 
  • yourEditor.css
file, determines the order they will appear in the drop down, not the order that they are defined in 


  • ToolsFile.xml 































Tuesday, May 24, 2016

I was asked to help out another Sitecore partner with my experiences using Sitecore Print Experience Manager. Being this is my first blog,  its a little bit all over the show, but will hopefully help out other users implementing PXM

https://doc.sitecore.net/print_experience_manager

I have outlined some of our experiences below. We are using:

  • ·       Sitecore 8.1 Update 1
  • ·       PXM 8.0 Update 1



  
If you are using Sitecore 8.1 and ODG you’ll need to get the fix Sitecore support put together to fix issue with the SPEAK interface for the ODG, SPEAK was made over in 8.1 so some SPEAK modules will have issues.

Overview

PXM is a very cool bit of kit, essentially creating a simple doc starts with InDesign which has the Sitecore connector installed and configured to connect to your management server.

An InDesign document is actually just an XML doc so this is very well suited to being stored in Sitecore, the standard hierarchical construct is recreated in Sitecore with (loosely) a Doc>Page>Snippet tree structure. 

Snippets can be related to a single element on a page such as a text field, image field, Sitecore field.

Takeaway here: Since an InDesign doc is stored as Sitecore content, all Sitecore functionality (Workflows, security, API etc.) can be leveraged over what is essentially print content, let that one sink in! 

Installation

We followed the Sitecore doc for installation, but were also helped a lot by Mark Demeny’s video series on PXM


Wiring it all up is …. Easy when you have done it 10 times, complex the first time.

Things to watch out for

Overview

In a multi-server set up the publish process goes a little like this: (Simplified)

  • ·       Using a web service, Sitecore sends an INDD and XML file to a Publishing Cache folder on the InDesign Server (IDS) and calls the IDS service to process it.
  • ·       The IDS takes the INDD file and using the instructions in the XML file, creates the specified PDF and places it back on the management server in a folder that has been mapped as a virtual drive in the web root. 
  •       It then sends an email notification to the user with a link to the pdf, voila download.


·       So the Publishing cache on the IDS needs to be network accessible with permission for NETWORK SERVICE read / write

·       The publishing folder also needs to be the same so IDS can deliver the finished doc.
·       
      If you aren’t getting the full cycle working, permissions is a good place to look.
·       
      Also note if you set the PublishFolder up as a share, you need to put this into the Print Studio settings as the share name (\\) so when this information is passed to IDS it can look back at the CM and find the correct folder to publish to.

Config:

In a three server set up the installed services / modules looks like this:

CM
·       PXM – core module – App_Config>Includes>PXM>Sitecore.Print.Studio.config  - These is also config in the content tree Print Studio> App Settings>Publish Paths
·       ODG - App_Config>Includes>PXM>Sitecore.ODG.config
·       Dashboard Server  - Installs into Program Files (x86)>Sitecore  Config in program folder
·       InDesign Service - Installs into Program Files (x86)>Sitecore  Config in program folder
·       MMSQ – Set up through Server Manager

IDS

  • ·       IDS (IDS has its own InDesign Server Service, configured through an app in Program Files>Adobe>InDesign), this allows you to specify the port (potential issue the 64 bit version is not registered so you cant create the service, fix is in Mark Demeny’s video (https://www.youtube.com/watch?v=9Ir_aOAgukk&list=PL1jJVFm_lGnyq030ylG0YOM3S9OvdNbN0&index=5)
  • ·       InDesign Server Engine 2014 – this is an IDS plugin by Sitecore for IDS
  • ·       MMSQ


Make sure that the following is set up and matches across all configs:

  • ·       IDS Address and port number
  • ·       Microsoft Message que name
  • ·       Adobe application name
  • ·       Paths to logfiles


Again Mark Demeny’s video series highlight potential pitfalls around config.

Test by calling the respective web services on both the IDS and CM through a browser, instruction in the videos

My best friend in setting this up the first time was log files>

  • ·       Sitecore – Print.studio.log (through the usual log viewer)
  • ·       Log files for the dashboard service and InDesign processing service in your PxmPublishing subfolders.
  • ·       Log files on the IDS server

  
Creating a Simple PXM Project

  • ·       Grab your InDesign doc and open it in InDesign
  • ·       Create a new master document under Master Documents in the Sitecore >Libraries Window – this is a little fiddly if you aren’t an InDesign native, thanks Google. Master docs can also contain embedded elements that will be used on all page in a PXM project, (note that Master page elements can be overridden on individual pages in InDesign).

 ·       Save it back to Sitecore – this will be saved in the Media Library as an INDD file, this essentially        grabs the page layout, dimensions and styles (important for creating your brochure later)
  •  ·       Next create a new project and drag it to the project tab to start editing and adding pages and elements. You have the option to save content and content and layout for individual pages or saving all pages by choosing the root page element (from memory). To include Sitecore content (really the big advantage for PXM), you’ll need to make sure Print Studio is configured in the content tree under one of the settings node (sorry away from the site today or I’d be more accurate and include screenshots) to point to your starting content node. Then in InDesign , on the Content tab you can browse to a content item, and drag and drop individual fields to your InDesign doc and save them back as snippets.


·       On save the PXM project is created under the Print Studio>Projects folder and you can also tweak nodes, styles etc. here too.


That’s it once over very lightly, areas where you may wish to customise:

  • ·       SPEAK interface
  • ·       Custom field renderers (for example to do look ups based on Sitecore field values or create a table of contents from a Content node construct)


At this stage we are only using the ODG to allow sales staff to create customised PDF’s using Sitecore content through the Document Publisher. This is done on the CM so we haven’t had to fool around with the CDs just yet, but assuming connectivity is all good shouldn’t be a problem.

SDN has a basic project to get you rolling here:



As far as InDesign goes, my golden rule is garbage in, garbage out, make sure your INDD doc is clean of spurious elements such as path generated elements – you can just cut n paste an existing INDD doc in, but I have had better success creating it element at a time to avoid adding unnecessary snippets to the project. 

(Tip: If you need to hide snippet elements in the ODG, create a new template inheriting from snippet and apply to hide snippets, the ODG work on GUID so they won’t be shown but will still get published)

Disclaimer: I wrote this blog from memory without actually sitting in front of the environments, so path / file / content node names may vary slightly.

Disclaimer 2: If I have anything fundamentally wrong, feel free to comment, Sitecore is all about continuous learning.

Thanks for reading