Using Notes forms to manage CSS files, templates and components
The first decision to make: render all the HTML with a QueryOpen agent in a Notes RichText field and hiding all the rest of the form for browsers. Then you need a Notes form for the CSS and a Notes form for the templates. Here's how I've made the CSS form:
The CSS form
This is a simple Notes form, maintained in the Notes client (we don't want to give normal users access). The fields used:
- A subject field for the label in the 'Select stylesheet' combo box.
- A page key for the URL.
- A rich text field to add file attachments.
- The Data_Raw field to enter the CSS rules themselves
Then there's a computed field that converts the image names in the CSS to their full URLs. This is the field that is actually rendered. 'FriendlyKey' and 'DbPath' are fields to hold the key value of the document in a 'pub' view and the path of the database:
@ReplaceSubstring(a; b; c)
The form itself is rendered with content type: other -> text/css.
Selecting the CSS
On the Site document, there is a combo box 'Stylesheet' which allows you to select the CSS document for this site. The options are taken from a computed for display field:
a:=@DbLookup("";""; "lookup"; "css"; 3);
@If(@IsError(a); @Text(a)+"|"; "(none)|":a)
Next, the HTML for the stylesheet is computed in a field:
a:=@If(StyleSheet=""; ""; "<link rel=\"stylesheet\" type=\"text/css\" href=\""+StyleSheet+"\" />");
The query-open agent can then just take this HTML and render it on the page.
The Template form
This forms stores both page templates as reusable HTML components. As in the CSS form, a similar computation is used to resolve the paths of the attached files. The same form is used both for reusable HTML components (header and footer) as page templates, because they are both just HTML texts. Again, on the Site document, you can select the header and footer components and the page templates to use for each page type:
Here's an example of how such a template looks like:
In a next post, I'll explain how I resolve the [%tags%] in LotusScript. As a reminder: this is part of the SiteBuilder I'm programming this weekend. Next thing to tackle for me is the creation of sections and the navigation.