Friday, January 25, 2002


Using Multiple Styles When Rendering
Mark Paschal is my hero for the day. With this innocuous string of posts in the RU Discussion forum he shed light on my problem.

I want to create a simple story that includes a table in it. I want the bulk of the story to be a Two Level Outline (headlines and subtext), but I also want to include a table in its midst. In Radio/Frontier terms that usually means creating two files, each using a unique renderer, and then merging the two. Up until now I had not been able to pull this off in Radio 8. I now have, thanks again to Mark.

The Solution
Let me start with the files to be rendered, that should make things clearer. The file below is the main document - newEmployeeReview.opml. As the directives state, it is to be rendered using the "pikeRenderer". I have placed a macro in it that will pull in another file. This file is to be rendered using a different renderer to save me the hassle of writing lots of HTML table code.

#title "New Employee Review"
#renderOutlineWith "pikeRenderer"
<rules> // omitted for clarity
	</rules>
A Plan For Bringing New Staff Up To Speed
	We all agree ... going over the topics below: 
	<%renderFile("misc/newEmployeeTopics.opml")%>

Here is the file representing my tabular data. As you can see, it is to be rendered using the "newTableOutliner". This is the same as the tableOutliner, but modifed to pick up the page table address correctly per Mr. Paschal's instructions.

#renderOutlineWith "newTableOutliner"
#flindex false
#cellpadding 2
#cellspacing 2
#border 0
#divColor "darkblue"
#cbgcolor "white"
#width "100%"
Topic
	Expert
Review Block Architecture Diagram
	Mark, Tony, Rene

The result is a nicely rendered table in the midst of my story - all appearing as a single document. Here is a copy of the renderFile macro I wrote, (also based on Mark's suggestions). Note that it assumes we are working with a document in the stories directory.

on renderFile(fpath) {
	local (foo, fname);
	local (pc = file.getpathchar ());
	local (folder = user.radio.prefs.wwwFolder + 
radio.data.folderNames.wwwStoriesSubFolderName + pc);
	fname = folder + fpath;	
	op.xmlToOutline (file.readWholeFile(fname), @foo, true);
	
	return renderObject(@foo);
}

There are a couple of other notes I should point out. I have added some othe rmods to newTableOutliner, thus the unfamiliar directives. I added the #flindex flag because my table is stored as an OPML document in a stories subdirectory. That means Radio will render it and list it in the Story index. I cannot easily help the rendering, but I really don't want this piece of document showing up in the index. I added a couple of lines to radio.macros.viewStoryList to look for the #flindex directive and skip the file if it is present.

I am one happy camper! Thank your Mark P.!!!
5:10:10 PM  [Macro error: The file "D:\Program Files\Radio UserLand\www\#prefs.txt" wasn't found.]