plugin:template
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:template [2009-10-07 00:08] – 82.237.128.230 | plugin:template [2019-09-10 20:05] (current) – Aleksandr | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
author | author | ||
- | email : http:// | + | email : |
- | type : | + | type : |
lastupdate : 2005-09-09 | lastupdate : 2005-09-09 | ||
compatible : | compatible : | ||
Line 12: | Line 12: | ||
similar | similar | ||
tags : extension, command, template | tags : extension, command, template | ||
- | ---- | ||
+ | downloadurl: | ||
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
+ | ---- | ||
===== Overview ===== | ===== Overview ===== | ||
- | The **Template Command** renders a data set from a template. The data set is just a [[:DokuWiki]] page containing a series of lists representing records (< | + | The **Template Command** renders a data set from a template. The data set is just a DokuWiki page containing a series of lists representing records (< |
This command is useful for... | This command is useful for... | ||
- | * Representing data in [[:DokuWiki]] separately from its formatting. | + | * Representing data in DokuWiki separately from its formatting. |
* Applying repetitive formatting to each of multiple data items. | * Applying repetitive formatting to each of multiple data items. | ||
- | * Generating rich HTML for inclusion in a [[:DokuWiki]] page. | + | * Generating rich HTML for inclusion in a DokuWiki page. |
- | * Expressing | + | * Expressing DokuWiki-maintained data in rich HTML. |
- | The command defines a kind of page called a //data page//. A data page is just a series of DokuWiki [[: | + | The command defines a kind of page called a //data page//. A data page is just a series of DokuWiki [[:wiki: |
A template command takes optional parameters, a template file name, and the name of a data page. Here are some example uses: | A template command takes optional parameters, a template file name, and the name of a data page. Here are some example uses: | ||
Line 39: | Line 45: | ||
</ | </ | ||
- | The parameters are handed to the template file, allowing for parametrized templates. The template file may produce either HTML or DokuWiki [[:syntax]] that is in turn translated to HTML --- which ever is easiest for the template writer. | + | The parameters are handed to the template file, allowing for parametrized templates. The template file may produce either HTML or DokuWiki [[:wiki:syntax]] that is in turn translated to HTML --- which ever is easiest for the template writer. |
Here are two demo pages that are generated by this command: | Here are two demo pages that are generated by this command: | ||
Line 102: | Line 108: | ||
===== Data Page Format ===== | ===== Data Page Format ===== | ||
- | A data page is a page that represents a set of records. Each record is a DokuWiki [[: | + | A data page is a page that represents a set of records. Each record is a DokuWiki [[:wiki: |
Here is an example data page: | Here is an example data page: | ||
Line 157: | Line 163: | ||
Text that appears before the first list item of a record is ignored and may be used to comment the page or the record. Note that DokuWiki needs a blank line before each horizontal rule. Records not containing any list items are ignored and are not handed to the template. This happens when two horizontal rules appear back-to-back or when one appears at the start or end of the file. | Text that appears before the first list item of a record is ignored and may be used to comment the page or the record. Note that DokuWiki needs a blank line before each horizontal rule. Records not containing any list items are ignored and are not handed to the template. This happens when two horizontal rules appear back-to-back or when one appears at the start or end of the file. | ||
- | Note that the '' | + | Note that the '' |
Whitespace preceding or trailing each '' | Whitespace preceding or trailing each '' | ||
Line 163: | Line 169: | ||
===== Template Files ====== | ===== Template Files ====== | ||
- | A template file is a file that uses PHP to generate HTML or DokuWiki [[:syntax]] from a data set. The file is placed in the active '' | + | A template file is a file that uses PHP to generate HTML or DokuWiki [[:wiki:syntax]] from a data set. The file is placed in the active '' |
How a template file works can be summarized in a few points: | How a template file works can be summarized in a few points: | ||
- | - Think of the file as a regular HTML or DokuWiki [[:syntax]] file that may contain embedded PHP. Everything outside of the PHP tags and all output echoed by PHP becomes part of the generated result. | + | - Think of the file as a regular HTML or DokuWiki [[:wiki:syntax]] file that may contain embedded PHP. Everything outside of the PHP tags and all output echoed by PHP becomes part of the generated result. |
- The PHP in the file runs within an outer, invisible PHP function. All this means is that you must declare any globals you want to use. | - The PHP in the file runs within an outer, invisible PHP function. All this means is that you must declare any globals you want to use. | ||
- The '' | - The '' | ||
Line 174: | Line 180: | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
All field values are reported with preceding and trailing whitespace trimmed. Note that in records retrieved via '' | All field values are reported with preceding and trailing whitespace trimmed. Note that in records retrieved via '' | ||
Line 181: | Line 187: | ||
===== Source (template.php) ===== | ===== Source (template.php) ===== | ||
- | <code php><? | + | <file php template.php> |
+ | <?php | ||
/** | /** | ||
* Template Command: Render a data set from a template. | * Template Command: Render a data set from a template. | ||
Line 602: | Line 609: | ||
} | } | ||
} | } | ||
- | ?></code> | + | ?> |
+ | </file> | ||
===== Examples ===== | ===== Examples ===== | ||
- | Bear in mind that, although the following examples generate HTML, the template file may instead generate DokuWiki [[:syntax]] by calling '' | + | Bear in mind that, although the following examples generate HTML, the template file may instead generate DokuWiki [[:wiki:syntax]] by calling '' |
Line 690: | Line 698: | ||
$side = ($side == ' | $side = ($side == ' | ||
} | } | ||
- | ?></ | + | ?> |
+ | </ | ||
> Note that the JavaScript function " | > Note that the JavaScript function " | ||
Line 697: | Line 706: | ||
===== Discussion ===== | ===== Discussion ===== | ||
- | * The template command allows the user to name any file in the [[:DokuWiki]] '' | + | * The template command allows the user to name any file in the DokuWiki '' |
* The example links (http:// | * The example links (http:// | ||
- | * <del>[[:DokuWiki]] syntax is not processed if I simple make the template '' | + | * < |
- | * First, thanks for this plugin :) . I encountered some problems using this plugin with the [[http:// | + | * First, thanks for this plugin :) . I encountered some problems using this plugin with the [[plugin: |
===PHP error=== | ===PHP error=== |
plugin/template.1254866905.txt.gz · Last modified: 2009-10-07 00:08 by 82.237.128.230