ASP | CMS Blog Watch

ASP

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

Posted in ASP, CMS, Chad Killingsworth, PreExecute, Quotes, RedDot, Templating, Tricks, VBScript, Workaround, escaping on April 26th, 2010 by Markus Giesen – Comments Off
How to handle quotes in standard text elements with VBScriptHow to manage Quotes, Placeholders and Pre-Execute using VBScript within RedDot CMS / Open Text Management Server

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:

<!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.

<!IoRangePreExecute>
<script language="javascript" runat="server">
  var PlaceholderValueRegExp = /^function [_a-zA-Z][_a-zA-Z0-9]*\(\s*\)\s*\{\s*\/\/([\s\S]*)\}$/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.

How does this work? What’s Behind the Magic Curtain?
Read more »

Share and Enjoy:

Print
email
Twitter
Digg
Reddit
StumbleUpon
Google Bookmarks
del.icio.us
MisterWong
Facebook
LinkedIn





Creating a Youtube video template for RedDot CMS

Posted in ASP, CMS, RedDot, RedDot template, Templates, Templating, YouTube on February 15th, 2010 by Markus Giesen – Comments Off

Would you like to give your editors the possibility to add Youtube videos to your RedDot CMS project?
But you don’t want them to be able to edit the HTML directly to enter the iframe tag that youtube provides and you don’t just want to add a link to the youtube URL because that would drive content from your site to youtube and the marketing department definitely wants visitors to stay on your site, right? Right.

Well, use this template, inspired by Kim Dezen to embed yutube videos by just entering the URL. The ASP code strips out everything but the video-ID and embeds the content into your project page without editors touching the HTML.

Explanation
<%stf_youTubeURL%> – Holds the complete URL to the youtube video.
This part removes the URL and returns just the youtube video id used for the embedded object tag.

<%
  youTubeID = Mid("<%stf_youTubeURL%>", InStrRev("<%stf_youTubeURL%>", "?")+3)
%>

Get the code

Donate a dollar or $2 and then download the template here. The code is a plain text file for you to copy and paste, you still have to create the element(s) yourself and do some thinking around this.

Licensing

Creative Commons License
YouTube video template for RedDot CMS by Kim Dezen is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Australia License.
Based on a work at www.reddotcmsblog.com.

Share and Enjoy:

Print
email
Twitter
Digg
Reddit
StumbleUpon
Google Bookmarks
del.icio.us
MisterWong
Facebook
LinkedIn





Debugging PreExecute ASP – Reloaded

Posted in ASP, CMS, Debugging, Management Server, Open Text Web Solutions Managment Server, PreExecute, RedDot, Tools, Tricks on November 4th, 2009 by Markus Giesen – Comments Off

Gavin Cope already came up this year with his great article on how to debug classic ASP script which runs in Open Text Management Servers PreExecute Mode. Keith Bloom picked up the idea and improved it a fair bit,
so that you now are able to

  • see the Error files as html files in your browser
  • open an overview page with all logfiles which are existing in the folder.

Modifications

WriteToFile "C:\Program Files\RedDot\CMS\ASP\PreExecute\logs\PreExecuteErrors_" & Year(Now) & Month(Now) & Day(Now) & _
".html", " Date/Time: " & Now() & "" & _
" ASP Code: " & objASPError.ASPCode & "" & _
"ASP Description: " & objASPError.Description & "" & _
" Category: " & objASPError.Category & "" & _
" Column: " & objASPError.Column & "" & _
" Description: " & objASPError.Description & "" & _
" File: " & objASPError.File & "" & _
" Line: " & objASPError.Line & "" & _
" Number: " & objASPError.Number & "" & _
" Source: " & objASPError.Source & "" & _
"############################################################" & "", True

This replaces the line .07 in Gavins code sample and writes the data with HTML line-breaks into a .html file.
Make sure your Program Files path is set correct.
Next step is to create a default.asp file (so that you just have to browse to the folder) or
ErrorList.asp file inside of the log file folder with the following code:

<%
sDirectory = "CMS/ASP/PreExecute/logs/"
sPath = Server.MapPath(sDirectory)

Set fso = CreateObject("Scripting.FileSystemObject")
Set currentFolder = fso.GetFolder(sPath)
Set fileList = currentFolder.Files
%>
<html>
	<head>
		<title>Open Text Websolutions : PreExecuteErrors
	</head>
<body>
	<h1>List of files

	<ul>
		<% For Each file in fileList %>
		<li><a href="<%= sDirectory & file.Name %>"><%= file.Name %>

		<% Next %>
	</ul>
</body>
</html>
<%
Set fileList = Nothing
Set currentFolder = Nothing
Set fso = Nothing
%>

This should list all error files within your log folder.

Thank you

Again thank you guys for share this ASP solution with us and spending some time on publishing it. Hopefully there will be a day when the CMS runs entirely in .NET as fastest available development language and we can use this within Open Texts Web Solutions Management Server to make the CMS world a better place..
;-)

Share and Enjoy:

Print
email
Twitter
Digg
Reddit
StumbleUpon
Google Bookmarks
del.icio.us
MisterWong
Facebook
LinkedIn





Duplicate content publishing – SEO and Open Text Web Solutions

Posted in ASP, Best practice, CMS, Featured, MainLink, PageBuilder, RedDot, RedDot CMS Shortcuts, Render Tags, Tricks, publishing on October 26th, 2009 by Markus Giesen – Comments Off

When pages are connected to multiple links allover the project – for example by using keywords – you will end up with one page published multiple times in several folder. This leads to duplicate content and search engines like Google, Yahoo, Bing, … basically any engine crawling your page will assume that you are trying to get a higher ranking by duplicating your content and keyword density. This can unfortunately lead to a full exclusion from Google’s search index and none of your pages within your domain would be found. Disturbing, isn’t it?

Why does it happen?

So why does the publishing of multiple pages happen?
Let’s have a look at the architecture of link elements within the Web Solutions Management Server RedDot CMS:
The PageBuilder is the core piece which follows the link structure of your Content Management Project and verifies every link and page within your project. Beside that the PageBuiler has been rewritten recently in .NET and shows now a performance than before when configured properly.

Different link types

There are two or furthermore three types of link elements:

  1. References
    they just reference/point to the origin place where a page “lives” within the project and
  2. Connected pages
    which can be expanded in SmartTree and are ‘truly connected’ to the link element
  3. Mainlink
    One exception is the Mainlink, this is the place where the page usually has been created at first and it defines the place where the page really lives in the CMS project.

What happens during publishing?

During the publishing process within WSMS RedDot CMS referenced links are not followed by the PageBuilder and hence don’t produce a published page follwing this link.
Connected pages to links are recognized by the PageBuilder which picks up the publication package assigned to the link and according to the settings in this package the page gets published. If a page is connected multiple times in a project, not just referenced, this structure creates multiple pages with the same content.

How do we solve multiple publishing?

We will convince the CMS PageBuilder that it is looking at a reference instead of a connected page link. The code for this is easy:

<%=Replace("<%list_teaser%>","islink=2","islink=10")%>

The only limitation here is:

  • The link element needs to be set to ‘insert path- and filename only’.
  • The code block runs in a prexecute so that the code is executed and returned as html when published

What the code does is that it replaces the link type

  • 2 = link, follow and publish the site based on the publication package attached to this link element
    to
  • 10 = reference, don’t follow this page and don’t publish it, just use the MainLink the page is connected to

The (almost) ready to go template code



Attention:

  • Don’t forget to wrap the code above in a pre execute
  • The RenderTag in the href=” ” doesn’t show up properly in so replace “RenderTag” with the tag above as described in the comment

EXPLANATION: So what does this all do?


This code hides the link from the HTML structure. Although it is hidden now from the HTML it doesn’t stop the PageBuilder from following the link and publishing the page, so we have to replace the two link types as discussed above.

Render Tag Code? What do we do here with the Render Tag?

<%!! Context:Pages.GetPage(Guid:<%info_PageGuid%>).GetUrl() !!%>

This nice Render Tag sets the link URL to the MainLink of the page. If this is used everywhere all links will point to the same place and make sure that you won’t have duplicate content or unwanted sites published in the wrong place.

Other ways?

I am sure there are of course other ways to solve this issue and I am keen to read them below!

Share and Enjoy:

Print
email
Twitter
Digg
Reddit
StumbleUpon
Google Bookmarks
del.icio.us
MisterWong
Facebook
LinkedIn