I have a question regarding nested repetitions. I have an array of data that I want to output to a template (settings.html : see code below).
Code: Select all
<mos:tmpl name="settings">
<table class="contentpane">
<mos:tmpl name="parameters" type="condition" conditionvar="FIELD_TYPE">
<mos:sub condition="list">
<tr align="center" valign="middle">
<td align="left" valign="top">{ROW_LBL}</td>
<td align="left" valign="top">{ROW_PARAM}</td>
<td align="left" valign="top">{ROW_DESC}</td>
</tr>
</mos:sub>
<mos:sub condition="textarea">
<tr align="center" valign="middle">
<td align="left" valign="top">{ROW_LBL}</td>
<td align="left" valign="top" colspan="2">{ROW_PARAM}</td>
</tr>
</mos:sub>
</mos:tmpl>
</table>
</mos:tmpl>
Here is the code that sets up the $data array:
Code: Select all
$data[] = array();
$data[] = array( 'type' => 'list', 'lbl' => _PMS_NOTIFY, 'param' => $lists['notify'], 'desc' => _PMS_NOTIFY_DESC );
$data[] = array( 'type' => 'list', 'lbl' => _PMS_NOTIFY_MSG_INCLUDE, 'param' => $lists['ntfmsginc'], 'desc' => _PMS_NOTIFY_MSG_INCLUDE_DESC);
$data[] = array( 'type' => 'list', 'lbl' => _PMS_INCLUDE_SIGNATURE, 'param' => $lists['sig'], 'desc' => _PMS_INCLUDE_SIGNATURE_DESC);
$data[] = array( 'type' => 'textarea', 'lbl' => _PMS_SIGNATURE_TEXT, 'param' => $sigtextarea, 'desc' => '');
The data inside the $data array is then parsed by the following code (the function createTemplate is not shown here, but is defined in the code):
Code: Select all
function &createTemplate() {
global $option, $mosConfig_absolute_path;
require_once( $mosConfig_absolute_path.'/includes/patTemplate/patTemplate.php' );
$tmpl =& patFactory::createTemplate( $option, true, false );
$tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );
return $tmpl;
}
$tmpl = &createTemplate();
$tmpl->setAttribute( 'body', 'src', 'settings.html' ); // load settings tmpl
$keys = array_keys($data);
foreach ($keys as $k)
{
$tmpl->addVar( 'parameters', 'field_type', $data[$k]['type'] );
$tmpl->addVar( 'parameters', 'row_lbl', $data[$k]['lbl'] );
$tmpl->addVar( 'parameters', 'row_param', $data[$k]['param'] );
if ($data[$k]['desc']!='')
{
// only addVar if 'desc' isn't empty
$tmpl->addVar( 'parameters', 'row_desc', $data[$k]['desc'] );
}
$tmpl->parseTemplate ( 'parameters', 'a');
}
$tmpl->displayParsedTemplate( 'form' );
Code: Select all
pat-Warning: Template 'parameters' does not exist.
Can anyone help? I'm stuck
![Sad :(](./images/smilies/icon_sad.gif)
Cheers from
Ford