Genii Weblog

Handy tip for those generating HTML with Midas

Wed 6 Apr 2005, 04:47 PM



by Ben Langhinrichs
A question came up in the support forum today, and I find myself answering this sort of question quite often, so I might as well post it here for a more general audience.  The specific question was:
is there a way to add a target tag for attachment links when generating html? in other words, if we are generating html from rich text, and the resulting page will be in a frameset, and we want PDF files attached to documents to appear in their own separate window outside of the frameset, is there a way to do that?

we thought about parsing the resultant text, but we were hoping that there was a way to make the call within the tool.
Putting aside the specific question, the general goal is to make some modifications to the HTML generated.  Now, Midas offers a great many of these options, but often not the specific ones people request, so here is a more general answer.  Change the rich text before generating the HTML.  You don't even have to save the changes, because the HTML generation will use the modified rich text.  This sounds deceptively simple, but it is very powerful.  Want to add a disclaimer to the HTML at a specific spot?  Add it to the rich text before generation.  Want to get rid of a section in the HTML?  Remove it before generating the HTML.

Midas is very good at manipulating rich text, so use that fact!

The specific answer I gave follows this pattern exactly:
There is no such setting, but there is a solution which should work for you.  Rather than changing the links after generating the HTML, change them before you generate the HTML.  Just put in a loop such as:

Set rtchunk = rtitem.DefineChunk("URLLink 1")
While rtchunk.Exists
  Call rtchunk.SetTargetProperties("URLLink", |Target="newtarget"|)
  rtchunk.GetNextTarget
Wend
 
Just add code such as that above before you call GenerateHTML or ExportToHTML or anything else that uses the HTML generation engine.  

By the way, a bonus to this approach is that you could look at each link and decide to set different targets depending on the content of the link, or otherwise make very specific modifications that might be difficult with a general setting for the HTML generation engine.

Copyright © 2005 Genii Software Ltd.

What has been said:

No documents found