57065989C8584AB5804D2A9CE0B2E3D6
  • RedDot CMS Blog
  • 24.03.2017
  • EN

rdb: How to manage Quotes, Placeholders and Pre-Execute using VBScript within RedDot CMS

This is another great guest post by Chad Killingsworth from the Missouri State university. Chad is another RedDot Guru who comes up with neat solutions every now and then and also integrated the TinyMCE texteditor into Open Text Websolutions Management Server RedDot CMS.

A frequent task in RedDot Open Text CMS template construction is to assign the value of a placeholder to a string so you can perform some kind of logic on it.

Most of the time we get along very well with our beloved content management system, but sometimes we wouldlike to add some kind of special characters to our standard text elements. And this works fine for 99%, no matter what we do, we can add a copyright-character, trademark, .. pretty much everything.

But one thing always breaks, and this is not even RedDot’s fault, it’s a simple ASP or VBScript flaw. Take this example:

 PreExecute 
<!IoRangePreExecute>
<%
  dim label
  label = "<%stf_Label%>"
%>
<!/IoRangePreExecute>

If the <%stf_Label%> placeholder happens to contain an un-encoded quote, you'll get a server error. But sometimes you just really NEED a quote in the value. How do you handle this?
 

Strange Bedfellows

Server side JavaScript (or JScript) has long been supported, but rarely used, by Internet Information Server. In this case we can use the following code to correctly capture the value.

 PreExecute 
<!IoRangePreExecute>
<script language="javascript" runat="server">
  var PlaceholderValueRegExp = /^function [_a-zA-Z][_a-zA-Z0-9]*(s*)s*{s*//([sS]*)}$/i;
  function GetPlaceholderValue(PlaceholderFunctionString) {
    var str = PlaceholderFunctionString.match(PlaceholderValueRegExp);
    if(str != null && typeof(str) == "object")
      return str[1];
    else
      return "";
    }
    if(!stf_Label<%PageID%>)
      function stf_Label<%PageID%>(){
        //<%stf_Label%>
      }
</script>
<%
  dim label
  label = GetPlaceholderValue(stf_Label<%PageID%>.toString())
%>
<!/IoRangePreExecute>

And presto – you have your variable and your quotes too.

       

Downloads

 

QuickLinks

 

Channel