Tridion 2011 provides shortcuts for several actions to navigate the tree view in the GUI and open items.  However, many other operations do not have a hotkey available, such as the Publish Queue.  During a normal day I open the Publish Queue many times, often from a Component or Page view.  I also have minimized the ribbon toolbar and finding the Publish Queue button is still an effort.  I wanted a shortcut key to assign to the Publish Queue to bring it up.  In this post I’ll explain how I added the hotkey to the Tridion GUI using a GUI Extension and provide a way for you to further customize it with your own hotkeys.

Code published at https://github.com/rcurlette/Publish-Queue-Shortcut

Update:  Big thanks to @puf for the comments.  Code is updated to reflect them.

Step 1:  Create the Folder for the GUI Extension.  I created the folder for the GUI Extension:  C:\Program Files\Tridion\web\WebUI\Editors\Shortcuts

Step 2:  Add the js files

For this extension I am using an external js library called Mousetrap, http://craig.is/killing/mice.  It is an excellent library, stand-alone, no dependencies, and only 1.6kb when minified.  This is important to know because the js library will load on every GUI view.

Create a js folder in the Shortcuts folder and put the mousetrap.min.js file there.

Step 3:  Adding our shortcut

Create another js file and call it mousekeys.js.  This is the place we’ll define our shortcuts and map them to GUI Javascript calls.

The below code was borrowed and adapted  from Albert Romkes excellent post about adding js files without showing a GUI element.   http://albertromkes.com/2012/01/30/tridion-gui-extensions-how-to-load-a-javascript-without-showing-a-gui-element/

/js/mousekeys.js

//If you only want your code to affect certain screens/views, you should listen to Anguilla events like this:
$evt.addEventHandler($display, "start", onDisplayStarted);

// This callback is called when any view has finished loading
function onDisplayStarted() {

	// Open Publish Queue dialog
	Mousetrap.bind('q', function() {
	                // UPDATE:  Below is the easy way to do it.  Make sure to update your Shortcuts.config to include the CME dependencies.  Big thanks to Frank van Puffelen (@puf) for the suggestion!
                        $commands.executeCommand('PublishingQueue')

			//var popup = $popup.create($cme.Popups.PUBLISH_QUEUE.URL, $cme.Popups.PUBLISH_QUEUE.FEATURES);
			//popup.open();
	});

    $evt.removeEventHandler($display, "start", onDisplayStarted);

    //alert($display.getView().getId());

   //if ($display.getView().getId() == "ComponentView") {
		//alert('comp view');
   //}
}

Step 4:  Finding the js call for the Tridion functionality

Using Firebug I inspected the Publish Queue button and then searched through the GUI js using Firebug Script window and found the code to open the Publish Dialog.  I feel lucky to have found it and that it worked.  :)  This is not always so easy and you might want to do some research before planning on mapping a shortcut to a favorite functionality, like checking-in or checking-out TBBs.  (if you do figure out how to do this pls leave a comment!)  :)  What other hotkey mappings would you like to see?

Step 5:  Create the config file for the extension

For me this was the first time using the domain model element within the config node.  It is a distinct difference between the normal method of having the cfg:file set node under the cfg:group node.

Shortcuts.config

<?xml version="1.0" ?>
<!--
    Tridion Hotkeys Extension

    Copyright (C) 2012 Robert Curlette
-->
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge" xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration" xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions" xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
  <resources cache="true">
    <cfg:filters/>
    <cfg:groups>
      <cfg:group name="Curlette.Shortcuts" merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor" merge="always">
          <cfg:domainmodel name="MousetrapDomain">
            <cfg:fileset>
              <cfg:file type="script" id="mousetrapLib">/js/mousetrap.min.js</cfg:file>
              <cfg:file type="script" id="mouseKeys">/js/mousekeys.js</cfg:file>
            </cfg:fileset>
            <cfg:services />
          </cfg:domainmodel>
          <cfg:dependencies>
            <cfg:dependency>Tridion.Web.UI.Editors.CME2010</cfg:dependency>
            <cfg:dependency>Tridion.Web.UI.Editors.CME2010.commands</cfg:dependency>
          </cfg:dependencies>
      </cfg:group>
    </cfg:groups>
  </resources>
  <definitionfiles/>
  <extensions>
    <ext:editorextensions>
      <ext:editorextension target="CME">
        <ext:editurls/>
        <ext:listdefinitions/>
        <ext:taskbars/>
        <ext:commands/>
        <ext:commandextensions/>
        <ext:contextmenus />
        <ext:lists/>
        <ext:tabpages/>
        <ext:toolbars/>
        <ext:ribbontoolbars/>
      </ext:editorextension>
    </ext:editorextensions>
    <ext:dataextenders/>
  </extensions>
  <commands/>
  <contextmenus/>
  <localization/>
  <settings>
    <defaultpage/><!--/Views/Default.aspx</defaultpage>-->
    <navigatorurl/><!--/Views/Default.aspx</navigatorurl>-->
    <editurls/>
    <listdefinitions/>
    <itemicons/>
    <theme>
      <path/><!--/CSS/</path>-->
    </theme>
    <customconfiguration/>
  </settings>
</Configuration>

Step 6:  Add the GUI Extension to the GUI
C:\Program Files\Tridion\web\WebUI\WebRoot\Configuration\System.config

<editor name="TridionShortcuts" xmlns="http://www.sdltridion.com/2009/GUI/Configuration">
<installpath xmlns="http://www.sdltridion.com/2009/GUI/Configuration">C:\Program Files\Tridion\web\WebUI\Editors\Shortcuts</installpath>
      <configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration">Shortcuts.config</configuration>
      <vdir xmlns="http://www.sdltridion.com/2009/GUI/Configuration">Shortcuts</vdir>
</editor>

Step 7:  Flush browser cache and try it.

Press the ‘q’ key in any window.  The moustrap js library does not work if you are in a text box or an input element, even if you use the ctrl-q key instead of ‘q’ as a hokey.

Code published at https://github.com/rcurlette/Publish-Queue-Shortcut

Summary

The GUI Extension framework allows us to easily enhance and enrich the User Experience using existing js libraries.  However, we should use care when adding libraries since they will be loaded with each GUI View and any errors in the js code will break the GUI.  To find out if your extension is breaking the gUI you can quicly comment it out in the System.config file and be back to normal very quickly.  I hope you enjoy using this and it makes it easier and quicker to view the Publish Queue.

Habits and Goals

July 16th, 2012 | Posted by Robert Curlette in Lifehacking - (0 Comments)

This is a non-technical and non-Tridion blog post.   This post is about habits – and how habits control more of what we do – or don’t do – than any other force.

Earlier this year I made a commitment to myself to post 1 time per week about Tridion.  This was my goal – and from it created some new habits.  However, recently I have not kept up the pace – falling behind on my weekly posting – and letting it slip.  I felt it slipping, making excuses to myself that it doesn’t matter a few more days – but the real crisis was I let go of my good habits – and without them I can’t get back to my weekly posting.

Recently I started reading a book on habits, The Power of Habit: Why We Do What We Do in Life and Business, – creating new habits as a necessity to reach an amazing, almost impossible goal.  And I realized this was the reason for my blog posts slipping – I lost my habits.  I related to the first story in the book where a woman imagines achieveing an almost impossible goal – and re-arranges her life to achieve it.  The example in the book tells of a woman wishing to travel through the Egyptian desert.  She imagines all the necessary training and conditioning she’ll need to do it – and then sets her mind on it.  It is impossible for her to do it at that time and she gives herself one year to get ready.  In the process she decides that she cannot smoke and also takes up running.  For me, posting on my blog every week on a Tridion topic also felt like an impossible goal, but exciting, with a potential trip to Portugal if I kept it up (Tridion MVP), and this was my ‘Egypt’ to work hard for.

When posting regularly, I noticed these good blog habits:

– Must have blog post idea before Saturday

– On weekend, spend 2-3 hours before lunchtime on the idea – try to write the blog post and get the code sample working

– Block time to continue on code sample and detailing the blog post on Mon / Tues.

– Post blog before Friday

These habits crowded-out other non-productive habits such as excessive time reading other blog posts / twitter, procrastinating, focusing on other non-Tridion technical topics, etc.  My goal and focus each week is the magical 2-3 hours on the weekend – and to have a gelled concept ready before then.  I know if this happens – the rest will follow through and work.  Losing track of this goal and these habits created a less productive and more boring week for me – the excitement of learning and sharing was gone, replaced with consuming content from other people’s twitter list and alternative programming languages and techniques.  But, I enjoy reading about other ways to do things and believe it increases my reach of solutions – but within a certain limit, and in a certain timeframe.

I recently followed Hacker News on twitter and the amount of interesting and non-relevant (non-Tridion related) articles is amazing.  I was reading these articles first thing in the morning – I loved it – learning new things (I thought) and then starting the day.  The problem was I was not learning new things – I was not practicing the techniques and they also didn’t help me with my Tridion-related projects or blog posts.  These articles were essentially noise and distracting my mind from my weekly focus.  Worse of all, I was doing this first thing in the morning – my most productive creative time of the day!  If I track back to when I slowed down blog posting and started following hacker news it correlates strongly.

A few years ago I put my TV in storage – I didn’t want to create the habit of sitting down every day afterwork and scrolling through the TV channels.  Of course, it helped 90% was in Dutch and I couldn’t understand it – but still, I wanted to explicitly chose what I watched rather than browsing through the channels.  I still love a good move and often go to the cinema or download a nice movie or series.

Little did I know that my twitter obsession with Hacker News was the same.  Twitter was my new TV and scrolling the posts was the same as browsing the TV channels – adding extra noise to my life.  I am not suggesting that we live in a cave and don’t get input from outside – but I am suggesting we control when we receive the input (after lunch or in a non-creative time) and we also control the source of the input.

Finally, knowing when we are most productive and limiting or removing other distractions is critical if we want to be successful at creating new things and contributing our ideas to our communities.  I hope to re-find my blog rhythm and start posting more frequently.  My first steps are to limit my content consuming activities to the afternoon, come up with a new blog post concept before Saturday, set aside first hour of the day for creative work (programming, writing) and finally using my born-again goal of weekly posting to crowd out the less productive bad habits I produced over the last few months.

I wish you many more successful habits and staying in the flow of your day.