
|
|
|
Pagenews website
|
|
|
|
|
|
|
|
|
|
|
|
Pagenews website
Copyright (C) 2004,2005,2006
by Philipp Kindt
|
|
The Donparser template
Content
Introduction
Specifications
Template syntax
Handler types
Introduction
Donparser is an interface between HTML and Perl. It is used as "backend" of Pagenews -
allmost everything uses it.
The classic way of writing Perl CGIs is that a perl script sends some HTML to the browser.
The donparser way is different: A .donparser - document is opened by a perl script that interprets
it and sends the content to the browser. Theese documents are normal HTML files with some
extensions that are just interpreted by donparser
.donparser - Documents can be found in three folders:
- cgi-bin/restricted/templates/user: all templates reachable by your website's visitors.
- cgi-bin/restricted/templates/internal: all templates which contain the Pagenews admin webinterface
- cgi-bin/restricted/templates/drafts: drafts are templates you can derive your own templates from when creating a new one
Specifications
Donparser document must have the ending .donparser.
There is a header which is separated from the rest of the template by an empty line.(\n\n)
The header is parsed and sent to the browser just like the rest of the template.
The only difference between header and footer is that the header is not shown (and not editable)
within the template editor of the web interface. It is designed to contain the template's configuration. If you ue the template editor only, you won't need it.
The document is a html file mixed with donparser handlers.
To edit a template, the best way is to open it in the webinterface's template editor.
Template syntax
This part shall explain the syntax of donparser handlers.
You do not need to understand what the handlers do at this point.
Donparser documents are normal HTML documents that include donparser handlers.
These handlers are marked by brackets: [HANDLER].
Most times, handlers begin with the type of the handler.
A valid example is [BROWSERPARAM myparam].
There are allso handlers without type definition, for example [DNSTANDARD_VERSION].
Handlers are replaced by the parser with their specific values during the parsing process.
[DNSTANDARD_VERSION] would insert the curent version of Pagenews right into the HTML
document, for example.
Handler-in-Handler constructions are valid: [FUNCTION]
[BROWSERPARAM functiontocall]] would
call the perl function which is given by the browserparam functiontocall.
([BROWSERPARAM field] means that the value of an <input name = "field"> would be
inserted to the document - see later)
Donparser works from inner to outer handlers - that means you can be sure a handler within
another handler is parsed before the handler that sourrounds him.
even [FUNC[BROWSERPARAM completeit] myfunction] would work - for example if the form field "completeit" had the value "TION", the function "myfunction" would be called.
Fancy, he?
Most handlers have a type identifier: [TYPE myhandler arg1 arg2]... where TYPE
can be for example "FUNCTION", "BROWSERPARAM,etc.
Simple replacement handlers come without a type identifier:
[DNSTANDARD_VERSION] for example
What, if arguments have a whitespace within? Use the quote notation.
[FUNCTION "myfunction" "arg1" "arg2"] is valid.
You can leave away the quotes for the first argumentsm (=leftmost), but once you used them, you must go on using quotes for everything that follows on the right.
For example, [FUNCTION "myfunction" arg1 arg2] would be invalid,
[FUNCTION myfunction "arg1" "arg2"] is valid.
Handler Types
(When "calling template" is mentioned, the template which contains the handler is ment.)
-
Filehandlers - [FILE myfile]
Opens the donparser-document "myfile" from the same directory the calling template is in,
parses it and inserts it into the calling template (replaces the handler).
-
Codehandlers - [CODE myperldocument]
Opens the file "myperldocument.pl" from the directory "cgi-bin/restricted/codehandlers" and executes the perl code. The code is loaded and the handler is removed. Once the code is loaded, it
is in memory and can be used in any template that is loaded within the template containing the CODE-handler, that is loaded below in the donparser source. This can be a FILE-handler or any other
possibility of including further templates.
-
Function handlers - [FUNCTION myperlfunc arg1 arg2]
Calls the perl function "myperlfunc". The function gets the current donparser object as its
first argument. The arguments arg1, arg2, ... (given by the handler) are following. The
handler is removed after parsing. Often, functions add simple replacement handlers (see below)
- Browser Parameters - [BROWSERPARAM myBrowserParam]
The handler will be replaced by the browser parameter myBrowserParam. Browserparams are submitted via the GET- or POST-method. For example, if a form is in a template which has
the element
<input type = "text" name = "myBrowserParam"> ,
and the form is submitted to a template which contains [BROWSERPARAM myBrowserParam], the handler will be replaced trough the value
of your text-input field!
Arguments can also be passed to templates by the URL, for example: news.cgi?myparam=myvalue&foo=bar
-
Remarks - [REMARK myremark bla bla]
This handler is just removed. It is added to the docuement object tree (=DOT, see below), but
has no special meaning. In addition to write small descripitons into templates, it can be used
to include information that can be read by looking it up in the DOT. For example, a
[DONPARSER_OPENBRACKET]REMARK template_type mytype] could be used to
set a type of a template.
-
Options - [OPTION myoption value]
Sets the donparser option "myoption" to the value "value".
See the options-section in the donparser documentation!
-
Simple replacement handlers and synonyms -
[MyHandler]
Simple replacement handlers are replaced through another text.
They are used to insert dynamic data. Simple replacement handlers are added by a function that
has been called before.In Pagenenws, there are some standard handlers, that are available without
a function having been called before. Example: [DNSTANDARD_VERSION] would display the current Pagenews version.
|
->
admin log-in
Powered by Pagenews DN 6.1.2 by Philipp Kindt
|