Filestpl howto



{{files_list>ns like '{CURNS}' ORDER BY f_name}}

files_list

{{files_href>fwd}}

files_href




<filestpl sql="ns like '{CURNS}' ORDER BY f_name">
file id: {ID}, name: {F_NAME}, size: {F_SIZE}<br>
</filestpl>

filestpl

other filestpl example:

<filestpl sql="ns like '{CURNS}:x' AND f_name like 'help_img_%.PNG' ORDER BY f_name">
file id: {ID}, name: {F_NAME}, size: {F_SIZE}<br>
</filestpl>






complex (my Wiki page buttom):

<div id="catlinks"><p class="catlinks">
<?php
echo( p_render( "xhtml", p_get_instructions( "{{files_href>fwd}}", "")));
?>
<table cellpadding="3" cellspacing="0" border="0">
<tr id="addN_0"><td class="files_td_data"><form class="files__form" method="POST" action="/tp/doku.php" accept-charset="utf-8" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo( $ID); ?>" class="files__form_hid">
<input type="hidden" name="do" value="show" class="files__form_hid">
<input type="hidden" name="files_id" value="" class="files__form_hid">
<input type="hidden" name="files_act" value="add" class="files__form_hid">
<input type="hidden" name="is_dir" value="N" class="files__form_hid">
<input type="hidden" name="files[0][is_dir]" value="N" class="files__form_hid">
</td>
<td class="files_td_data" colspan="3">&nbsp;<input type="file" name="files_file" class="files__form_input">&nbsp;</td>
<td class="files_td_data" colspan="3"><input type="text" name="files[0][comm]" value="" style="width:90px" class="files__form_input"></td>
<td class="files_td_data" colspan="3">
<input type="submit" name="submit" value="add" class="files__form_btn" title="add" />
</form>
</td></tr>
</table>
<?php
$dv_t = "";
$dv_t .= "<filestpl sql=\"ns='{CURNS}' ORDER BY f_name\">\n";
$dv_t .= "{DEL} {IS_NEW} {IS_DIR_S}: <a title='{SP_INFO}' href='/files_dav/{F_PATH}'>{F_NAME}</a> {SP_COMM}<br>";
$dv_t .= "</filestpl>";
echo( p_render( "xhtml", p_get_instructions( $dv_t, "")));
?>
</p></div>


buttom


doku_files' table fields:

  `id` bigint(20) NOT NULL AUTO_INCREMENT,
`ns` varchar(255) NOT NULL, // file namespace
`is_dir` SET('Y','N') NOT NULL, // IS directory?
`f_name` varchar(255) NOT NULL, // file real name
`f_type` varchar(64) NOT NULL, // file MIME type ("text/plain")
`f_size` bigint(20) NOT NULL, // file size IN bytes
`dt_add` datetime NOT NULL, // when ADD file
`user_add` varchar(64) NOT NULL, // who ADD file
`dt_upd` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, // when file updated
`user_upd` varchar(64) NOT NULL, // who updated file
`comm` varchar(255) NOT NULL, // comment

Ex0: show all files, attached to this page
<filestpl sql="ns='{CURNS}'">
{A}<br>
</filestpl>


Where {A} - is the special, there will be a LINK to the file instead of it.

output:

Adempiere.properties
AccountingUS.xls
AccountingUS.csv

Ex1: show all files from manual : filestorage page (URL: http://somesite.com/manual:filestorage)
  <filestpl sql="ns='manual:filestorage'">
{A}<br>
</filestpl>

output:
robots.txt


Ex2: show all files from this page, ordered by SIZE
  <filestpl sql="ns='{CURNS}' ORDER BY f_size">
{A}<br>
</filestpl>

output:
AccountingUS.xls
AccountingUS.csv
Adempiere.properties


Ex3: show all files, begins with “Acc*” from this page, ordered by SIZE
  <filestpl sql="ns='{CURNS}' AND f_name LIKE 'Acc%' ORDER BY f_size">
{A}<br>
</filestpl>

output:
AccountingUS.xls
AccountingUS.csv
* do not forget, the wildcard is not “*” in SQL. it is “%”!

Ex4: let’s show some more information, COMM field (comment)...
  <filestpl sql="ns='{CURNS}' AND f_name LIKE 'Acc%' ORDER BY f_size">
{A} // {COMM}<br>
</filestpl>

output:
AccountingUS.xls // Adempiere accounting XLS
AccountingUS.csv // Adempiere Accounting file

Parametrized templates howto

create variable and assign a value:
##TDvarname=varvalue##

use variable in plain page text on in any files templates definitions:
$$TVvarname$$

Do not try to do variable substition in any other wiki-formatted
blocks. Wiki paraser is not recursive, variable substition will not
work at blocks, like this:

*Bold $$TVvarname$$ Text**
Sorry, it’s Wiki parser limitation.
But you can use variables in plain text and in any files templates constructions. For example,

<filestpl sql='ns='{CURNS}' AND f_name='$$TVvarname$$' ORDER BY f_name'>
<a href='{LINK}/{F_PATH}' >{F_NAME}</a> ({F_SIZE}) {COMM}<br>
</filestpl>

this WILL work.

include any page in current page:

$$TInamespace:page$$


Example of the Wiki page text:

##TDproduct=pruduct1##

product name: $$TVproduct$$

Result page:

product name: product1


HOW IT LOOKS LIKE

Template page (tpl:product) 'as-is'
tpl_product

Template page (tpl:product) src
tpl_product_src


Some page (products:em203a) is using this template
em203a


It's (products:em203a) source

em203a_src