Archive for the 'RedDot CMS' Category

Page does not exist in language variant ENG.

Wednesday, September 17th, 2008

If you play with language variants in RedDot CMS, sooner or later you will come across pages in SmartTree that display with the above title - “Page does not exist in language variant ENG.” Don’t worry - it just means that the page exists in one of the other language variants and not the one you are currently viewing.

Well, mostly. What if you can’t find the language variant it exists in? What if you aren’t even *using* language variants? In these cases, the message is, at best, misleading. But never fear - the reason, and the solution, are very simple.

The reason is that RedDot CMS cheats (in my oppinion) in the method that it determines whether a page exists in a given language variant (and remember, you are always using at least one language variant!) Simply put, it checks the page headline. If the page headline exists, it shows it. If it doesn’t, it shows the message above. Obviously if we create an English language variant page, and no one has translated it into our Dutch language variant, the Dutch language variant version has no title, and RedDot correctly shows the above message.

So what is the issue? Well, if we *remove* the headline of a page (edit via form, delete the contents of the page headline) - RedDot can not distinguish this from a page missing in a language variant, hence the above message. The solution? Make sure all pages have a headline! You can fix an existing issue by simply adding the headline back in via the page properties. If the page truly does not exist in the language variant, you will not be able to edit the filename (it will be greyed out.)

Now you may be wondering why anyone would remove the page headline in the first place. Well, I can name two scenarios:

  1. A clever author (perhaps without delete or disconnect permission, perhaps unaware of how to) has realised that deleting the page headline removes the page (or component from the page.) (If RedDot CMS doesn’t think the page exists in this language variant, it will not display it.)
  2. An author has decided that their page (or component of the page) would look better without its title, and removed it the only way they know how - by deleting the headline.

The first scenario requires user training (or the removal of headline editing permission - but that may be overkill.) The second usually points to a deficiency in your template - consider adding an option placeholder to allow your authors to choose whether the headline is visible or not. Unfortunately, the headline placeholder does not allow you to make it mandatory - so it is still possible for it to be removed - so user training may still be required.

RedDot CMS and Publish Only

Monday, September 15th, 2008

As much as some people would like you to believe that preview is the same as publish, its not. Some of the differences are technical (for example, published URLs follow your publication struture, whilst preview URLs resemble SmarEdit URLs) and some of the differences are practical (there is hardly any need to connect to Google Analytics from your preview - and if there is, you probably want to use a different account number anyway…)

Now, RedDot CMS provides block marks for choosing to output code in SmartEdit mode or not in SmartEdit mode - which basically means preview *and* publish. So, how do we output code in publish mode only? Well, we have two options (that I am aware of) - pre-execute code or Navigation Manager.

Using pre-execute code, we need to be able to test against something that exists in preview or publish - but not both. Thankfully, the session object fulfills this requirement nicely. Below, the inf_loginGuid placeholder is an info element that outputs the login guid of the current user’s session.

<!IoRangePreExecute><?php if ('<%inf_loginGuid%>' == '') { ?>
Publish only content
<?php } ?><!/IoRangePreExecute>

My preference is to functionalise this, put it somewhere accessible to all templates, and then call the function - but thats just me:

<!IoRangePreExecute><?php
function isPublish() { return ('<%inf_loginGuid%>' == ''); }
?><!/IoRangePreExecute>
<!IoRangePreExecute><?php if (isPublish()) { ?>
Publish only content
<?php } ?><!/IoRangePreExecute>

Navigation Manager has a specific tag - Context:CurrentRenderMode - which will output the mode: 0 = preview, 1 = SmartEdit and 2 = publish. You can use this within regular Navigation Manager If statements (not covered here), or similiar to the examples above, ie:

<!IoRangePreExecute><?php if ('<%!! Context:CurrentRenderMode !!%>' == '2') { ?>
Publish only content
<?php } ?><!/IoRangePreExecute>
<!IoRangePreExecute><?php
function isPublish() { return ('<%!! Context:CurrentRenderMode !!%>' == '2'); }
?><!/IoRangePreExecute>

So, what’s the catch? Well, you need Navigation Manager activated in order for the Navigation Manager solution to work - and I wouldn’t recommend that unless you are actually using Navigation Manager (for one, it requires a server config file change). But the placeholder method works fine. I leave it as an exercise for the reader to work out how to output code in preview only using the placeholder method :)

RedDot CMS and RQL Documentation

Sunday, September 14th, 2008

Thought I had hit gold this morning. Playing around with my iPhone and RSS feeds, I happened to do a search for “RedDot blog” and came across this on the US community site: new cms 7.0 and 7.1 rql documentation released. Unfortunately, you need a US community site login to access it. Tried checking the UK community site (which I do have access to) but as I suspected, it isn’t there :( Is it only in the UK that this documentation seems to be pay to access? Anyway, if you have access to the US community site, I would be interested to know whether the RQL documentation is indeed free to access from the above link - along with whether it is the most up to date (the above is from February 2007). Meanwhile I guess it is back to the user and common logs for me…

RedDot CMS, SmartEdit and Lightbox

Saturday, September 13th, 2008

Sometimes, my previous article on RedDot CMS, SmartEdit and Javascript is just not enough - for example, integrating Lightbox (in this case, version 1). Now, there is probably not any really good reason to have Lightbox working within SmartEdit - but that is not the point of this post. No. The point of this post is to explore “why” Lightbox doesn’t work in SmartEdit, because, chances are, the Javascript library you *do* want to have work in SmartEdit is probably suffering the same issue. And any way - its an easy problem to solve :)

The symptoms of note here (apart from it not working) is that we also do not have any Javascript errors. Which generally means some clever Javascript is failing safe, or, more likely, the Javascript isn’t being run at all. Either way, we need to find where the Javascript begins running, and in this case, we happen upon the issue straight away at the bottom of the Javascipt file - extract below:

// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function'){
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(initLightbox);	// run initLightbox onLoad

As you hopefully can see, the call to addLoadEvent on line 17 (above) is supposed to start the initialisation of Lightbox. The addLoadEvent function (lines 5 through 15 above) takes a copy of the old onload function and replaces it with one that calls the old unload function followed by the supplied function. All would seem well - but it suffers one minor but important flaw - it relies on everything else playing just as nice with the onload event.

Now, when you are dealing with your own web sites or web applications, you are in control of playing nice and, well, it serves you right if you don’t. But when you deal with other peoples web sites or web applications, well, unless you want to start modifying them (assuming that you can *and* you wish to deal with whatever can of worms that opens) your other options are to *hope* that they play nice (not very effective) or work around it. Guess what we will be doing…

With respect to SmartEdit and the onload event - RedDot CMS does not play nice. In the previous article, we saw how in SmartEdit mode, RedDot CMS would happily add a HTML body tag to our page if it was missing one - whether it needed one or not. This time we are more interested in what it does to an existing HTML body tag - bludgeoning the onload attribute with its own code. And by doing so, it effectively overwrites what Lightbox had previously set up.

Thankfully, the solution is easy - we simply repeat the addLoadEvent call *after* RedDot CMS has output the HTML body tag:

<!IoRangeRedDotMode>
<script type="text/javascript">
/* <![CDATA[ */
  if ((typeof addLoadEvent == 'function') && (typeof initLightbox == 'function')) { addLoadEvent(initLightbox); } // Overide SmartEdit!
/* ]]> */
</script>
<!/IoRangeRedDotMode>

As the code is only necessary in SmartEdit mode, we use SmartEdit mode only block marks to remove the added code from preview and publish. I place the code at the end of the HTML output, between the closing HTML body and html tags, and also do some checks to confirm the existence of the functions - in case I have pages that do not include the Lightbox code.

Removing old RedDot CMS log and temporary files

Tuesday, August 26th, 2008

I had cause to investigate last week why a user defined job in RedDot CMS that had been set up to delete all common log files older than 3 days, once a week, wasn’t. The RQL for the job (below) looked fine. The permissions on the files and folders looked fine. Eventually, I emailed RedDot UK support…

<IODATA loginguid="[!guid_login!]">
  <ADMINISTRATION>
    <LOGDIR action="delete" donotlog="1" guid="Common" days="3" format="1"/>
  </ADMINISTRATION>
</IODATA>

… its a known defect (25320) - caused by the “days” parameter in the user defined job. However, if you do not use this parameter, all logs will be deleted. Apparently due to be fixed in RedDot CMS 7.5 SP2. I had also asked about any functionality to clear out RedDot execute and pre-execute temporary files (they were starting to overwhelm the ASP folder) - but there isn’t any. They did suggest I could write my own however…

So here it is - a VB script file for cleaning up your RedDot CMS log and temporary files. In fact, other than the specific file name matching, this could be used for any log or temporary file cleanup task - assuming you are on a Windows server anyway.

' E:\Program Files\RedDot\cleanupTempFiles.vbs
' This script is meant to run as a scheduled task once per week. It cleans up RedDot files older than 8 days.
' In E:\Program Files\RedDot\CMS\ASP: rdexecutetemp*.php, PreExecute_*_temp.php
' In E:\Program Files\RedDot\CMS\ASP\LOG\Common: *_RDCMS_Async.log, *_RDCMS.log, *_RdMailer.log, *_dberror.log
' 22/08/2008 Adrian Mateljan

cutoff = dateadd("d", -8, date)
cleanup "E:\Program Files\RedDot\CMS\ASP", "^rdexecutetemp.*?\.php$", cutoff
cleanup "E:\Program Files\RedDot\CMS\ASP", "^PreExecute_.*?_temp\.php$", cutoff
cleanup "E:\Program Files\RedDot\CMS\ASP\LOG\Common", "^.*?_(RDCMS|RDCMS_Async|RdMailer|dberror)?\.log$", cutoff

Sub cleanup(folderName, pattern, cutoff)
  Set fso = createobject("scripting.filesystemobject")
  Set folder = fso.getfolder(folderName)
  Set files = folder.files
  Set re = new regexp
  re.Pattern = pattern

  countFiles = 0
  countSize = 0

  For each file in files
    If re.Test(file.name) Then
      If file.datelastmodified < cutoff Then
        'wscript.echo "Deleting " & file.name & " last modified: " & file.datelastmodified
        countFiles = countFiles + 1
        countSize = countSize + file.Size
        On Error Resume Next
        file.delete
      End If
    End If
  Next

  wscript.echo "Deleted " & countFiles & " files from " & folderName & " [" & niceSize(countSize) & "]"

  Set re = Nothing
  Set files = Nothing
  Set folder = Nothing
  Set fso = Nothing
End Sub

Function niceSize(size)
  units = "B"
  If size > 1024 Then
    size = Round(size / 1024, 1)
    units = "kB"
  End If
  If size > 1024 Then
    size = Round(size / 1024, 2)
    units = "MB"
  End If
  If size > 1024 Then
    size = Round(size / 1024, 3)
    units = "GB"
  End If
  niceSize = "" & size & units
End Function

So - line 7 shows you how to set the cutoff date for removing files (in this case, anything older than eight days.) Lines 8, 9 and 10 show various examples of regular expressions used to match the RedDot CMS log and temporary files in question to be removed. Simply modify the cutoff date and filename matching to taste, set up as a scheduled task (possibly commenting out the wscript.echos) and you should be all set!

Note that we are using PHP in RedDot CMS - so the files have PHP extensions, not ASP or ASP.Net. A PHP version of this script next week… Enjoy!

RedDot CMS, SmartEdit and Javascript

Monday, August 18th, 2008

If you have Javascript in your website, and have implemented your Javascript files as templates in RedDot CMS (version 7.5), linked in to your HTML page via an anchor placeholder, you will most likely have come across this issue - your Javascript doesn’t work in SmartEdit!

The reason? RedDot CMS in SmartEdit mode does some mucking around with your template which causes Javascript errors. Take the simple Javascript template below:

function helloWorld() {
  alert("Hello World!");
}

In SmartEdit, this becomes:

<HTML><HEAD></HEAD><BODY ONLOAD="CheckAllTargets();" ><SCRIPT language="javascript" src="ioEditElement.js"></SCRIPT><SCRIPT language=javascript src="RDCleanHtml.js"></SCRIPT>
<SCRIPT language="javascript">var sInvertDirectEdit="0";var sRemoveFontSettings="1";var sRemoveStyleSettings="1";var sAllowedStyleAttributes="";</SCRIPT>
function helloWorld() {
  alert("Hello World!");
}

As you might expect - this isn’t valid Javascript, and basically the Javascript processing stops at the top of the file. We can eliminate this with a single line of code to our original Javascript file:

<!IoRangeRedDotMode>/* <body>RedDot decoy</body> */<!/IoRangeRedDotMode>
function helloWorld() {
  alert("Hello World!");
}

Now, when RedDot CMS renders the Javascript in SmartEdit, it will be conveniently fooled by our decoy HTML body tags (as shown below) and all will be well!

<!IoRangeRedDotMode>/* <body ONLOAD="CheckAllTargets();" ><SCRIPT language="javascript" src="ioEditElement.js"></SCRIPT><SCRIPT language=javascript src="RDCleanHtml.js"></SCRIPT>
<SCRIPT language="javascript">var sInvertDirectEdit="0";var sRemoveFontSettings="";var sRemoveStyleSettings="";var sAllowedStyleAttributes="";</SCRIPT>RedDot decoy</body> */<!/IoRangeRedDotMode>
function helloWorld() {
  alert("Hello World!");
}