Labels

accessibility (2) ADF (1) archiver (3) cmu (1) contributor (13) cookie (1) DAM (3) date (3) download (3) dynamic list (4) ephox (5) fatwire (1) fck (1) filters (1) folders (4) headers (2) IBR (3) ImageAlchemy (3) java (4) javascript (2) layout/template (4) link (6) locale (2) multilingual (1) rendition (3) replicator (4) rules (1) schema (1) search (11) sites (1) sitestudio (24) ssp/sspu (5) SSUrlFieldName (2) stellent (4) timezone (1) urm (1) weblogic (1) workflow (2)

Saturday 20 February 2010

Comparing Dates and Time Zones

Date and time calculations are a bit tricky in UCM. Unlike regular numbers, dates and times cannot be calculated or compared to one another directly.

Comparing numbers is easy, consider this example:
<$if 6 gt 5$>
This code is always true!
<$endif$>
Dates and times cannot be compared this way unless they are converted to numbers, using toInteger(). Unfortunately there is no way to turn that number back into a date, so it's not too useful. A better way to manipulate timestamps without converting them is to simply "parse" them, using the parseDate() function.
<$myBirthday = "5/3/77"$>
<$if parseDate(myBirthday) gt parseDate("18/09/1970")$>
I was born after Hendrix died, on <$myBirthday$>!
<$endif$>
Parsing a date depends on the format of the timestamp. There are many different formats for timestamps so you'll need to figure out which ones are used by your UCM installation. The system locale decides how to format and recognise timestamps. For example, the UK locale uses dates in d/M/yy format, whereas the US locale is M/d/y. The system locale and timezone are chosen when UCM is first installed. Users can choose to use their own locale and change the way dates and languages are displayed just for them. UCM will recalculate timestamps and present the correct timezone for the user's locale whenever they look at a date, but continue to store dates according to the system locale. Any dates that are entered need to follow the (user) locale's recognised date formats, which may or may not include seconds, military hours and so on. The system locale can be changed on reboot using the SystemProperties utility; the user local is easily switched from the Content Server "My Profile" page.

Apart from simple date/time comparisions, UCM can also do a great job at converting a given timestamp to the current timezone, adding daylight saving as required for us. You will need to tell it what timezone you are converting from by manually adding the timezone and then explaining the format of the timestamp. Use zz to indicate a timezone code. For example, let's convert the new year's countdown in New York to my local time (Sydney) and see when they'll join in on our party.
<$parseDateWithPattern("1/1/11 America/New_York",
"d/M/y zz")$>
Unfortunately there doesn't seem to be a built-in way of converting the local timestamp to a specified timezone. I get around this by calculating the difference between a date in local time and the same date specified as another timezone, then adding that difference to my local time. For example, when we're doing the new year's countdown in Australia, how far behind will the UK be?
<$newYearUK = parseDate("1/1/2011")
+ toInteger(parseDate("1/1/2011"))
- toInteger(parseDateWithPattern("1/1/2011 Europe/London",
"d/M/yy zz"))$>
One of the quirks I've observed with handling date objects is that errors are not reported in the server output log. Your code simply keeps going like nothing happened! This makes problems difficult to trace and you'll get unexpected results. It's a good idea to print out your timestamps as you manipulate them so you can see where any problems are.

**** UPDATE ****
Alec Kloss sent me an email with the following tip:
"...you should be able to go to any Content Server generated page and append
&UserTimeZone=America/Chicago
to the end of the URL and... that will change the timezone of all displayed times accordingly."
Nice one!

Wednesday 10 February 2010

Copy a SiteStudio site? Even easier!

SiteStudio 10gR4 (546) is chock full of awesome new features, one of which is a new way to replicate your site. Yes, the previous article I just wrote about replication is already obsolete. Ha!

The new feature is section level replication and it's pretty nifty. It is enabled via the Designer application and it adds a new section property, called "Ready to replicate." If you switch region content anywhere on a webpage, the property automatically changes to false. You can see this on your webpage in the contribution mode banner as a "replicate" or "don't replicate" button. Now I have to confess... I haven't got a system set up to test this new replication functionality but I assume it is all part of the Manage Site Replication page*. Archiver should rebuild the project file on import and ignore the sections where "Ready to replicate" is false. Why did I say Archiver "should" rebuild? I haven't found a shred of documentation to explain any of this stuff, I'm just guessing (it only got a mention in the release notes textfile.)

Some other awesome features in recent SiteStudio releases include:
  • Compare renditions - any renditions, not just the latest! On the Content Information page, in the revision history table, a new column is appended that allows you to compare the current revision to any other revision, future or past.
  • Setting a default page name (instead of manually changing index.htm)
    SSDefaultUrlPageName=default.html
  • Downloading images and documents from a friendly URL (the current directory) not the WebLocation (buried in the /groups/public/documents directories.)
    SSEnableDirectDelivery=true
  • Oh and those stubbornly clinging to the Ephox editor, don't forget the "ondemand" editors option that was included a few releases prior. It lets you say how many elements get loaded automatically and how many must be clicked on to load. If your page has more than three or four elements then Ephox (Java) is likely to hang your machine, so this setting is a godsend.
    SSUseOnDemandEditors=true
There's more great features too, so do yourself a favour and upgrade.

* UPDATE
Section Level Replication works great! I was right, it works via the "Manage Site Replication" page with Archiver. Note that the project file's native file is modified to exclude sections but not the weblayout file. Strange but true.

Monday 8 February 2010

How to copy a SiteStudio site

A question that pops up quite often how to copy a SiteStudio website, or maybe just a part of it. UCM is a content management system so by definition it tries to reuse content and prevent duplication! But there are situations where it is desirable to duplicate or replicate your site, like for a training demo or for backup purposes. There are a number of techniques to do this but surprisingly few people know how, or how do it really easily.

The best method for replicating site sections to another UCM instance is to use the SiteStudio Replicator application. This application can select individual website sections to replicate (or the whole lot.) It can also overwrite or retain the region content assignments on the target server, along with other section properties including custom section properties. A few simple clicks and the site structure is replicated. You don't need any firewall exceptions or UCM providers to connect the servers, you don't need to check in any content. Easy! It is already installed on your local machine alongside the SiteStudio Designer application, look for it in your Windows Start menu.

But we're still stuck on website duplication. There is an inherent problem here - website sections rely on unique section IDs - you can't simply duplicate a website, because you'll get duplicate website sections! If you really really need to duplicate a site or some site sections, download the project file xml and manually copy + change ALL the section IDs (append a letter to them all.) This is fraught with danger; the simplest mistake will cripple the entire website.

Other site replication methods include:

The Backup and Restore page basically downloads an entire site and all its config and bits and pieces and wraps it all up in a zip file. I suppose this is the cleanest way to backup a site but it doesn't duplicate a site. It has to be run manually and it creates a nasty big zip file. Not really useful unless you're doing a training demo and want to obliterate any changes when you import. It's in Content Server under the menu Administration > Site Studio Administration > Backup and restore.

The Manage Site Replication page uses the power of Archiver to replicate a site to another UCM instance with the benefit of running automatically as content changes. It can be configured to include the website content and/or the website structure (the project file which describes all the site sections.) The problem here is that it will replicate the entire site structure, which is typically not ideal. Most websites are constantly under development and require a planned launch, not an automatic deployment! It's best for synchronising content only, keep the project file out of it. It's in Content Server under the menu Administration > Site Studio Administration > Manage Site Replication.