Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 08:23 am EST
Geeklog Forums
Defining a template for a new plugin
Status: offline
Al262
Forum User
Junior
Registered: 10/19/10
Posts: 16
I've looked at the forum and searched thru some of the other plugins thought it might be best to surface a question.
I created a sample.thtml file, but want to understand best practice for setting sample_id and sample_desc as they will repeat based on the number of rows in the sample database table.
<table id="sample" class="tablesorter">
<thead>
<tr>
<th>{lang_sample_id}</th>
<th>{lang_sample_desc}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{sample_id}</td>
<td>{sample_desc}</td>
</tr>
</tbody>
</table>
I created a sample.thtml file, but want to understand best practice for setting sample_id and sample_desc as they will repeat based on the number of rows in the sample database table.
Text Formatted Code
<table id="sample" class="tablesorter">
<thead>
<tr>
<th>{lang_sample_id}</th>
<th>{lang_sample_desc}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{sample_id}</td>
<td>{sample_desc}</td>
</tr>
</tbody>
</table>
11
13
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hi,
All the magic of the template class is between <!-- BEGIN mysampleblock --> and <!-- END mysampleblock -->.
sample.thtml
<table id="sample" class="tablesorter">
<thead>
<tr>
<th>{lang_sample_id}</th>
<th>{lang_sample_desc}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN mysampleblock -->
<tr>
<td>{sample_id}</td>
<td>{sample_desc}</td>
</tr>
<!-- END mysampleblock -->
</tbody>
</table>
in your php file
$T->set_file ('mysample','sample.thtml');
$T->set_block('admin', 'mysampleblock','mysamplevariable');
for ( $i=0; $i < $nRows; $i++ ) {
$row = DB_fetchArray($result);
$T->set_var(array(
'sample_id' => $row['sample_id'],
'sample_desc' => $row['sample_desc']
));
$T->parse('mysamplevariable','mysampleblock',true);
}
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
All the magic of the template class is between <!-- BEGIN mysampleblock --> and <!-- END mysampleblock -->.
sample.thtml
Text Formatted Code
<table id="sample" class="tablesorter">
<thead>
<tr>
<th>{lang_sample_id}</th>
<th>{lang_sample_desc}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN mysampleblock -->
<tr>
<td>{sample_id}</td>
<td>{sample_desc}</td>
</tr>
<!-- END mysampleblock -->
</tbody>
</table>
in your php file
Text Formatted Code
$T = new Template($_CONF['path'] . 'plugins/myplugin/templates');$T->set_file ('mysample','sample.thtml');
$T->set_block('admin', 'mysampleblock','mysamplevariable');
for ( $i=0; $i < $nRows; $i++ ) {
$row = DB_fetchArray($result);
$T->set_var(array(
'sample_id' => $row['sample_id'],
'sample_desc' => $row['sample_desc']
));
$T->parse('mysamplevariable','mysampleblock',true);
}
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
11
10
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
It is a mistake of inattention. Can you try replacing
$T->set_block('admin', 'mysampleblock','mysamplevariable');
with
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
Text Formatted Code
$T->set_block('admin', 'mysampleblock','mysamplevariable');
with
Text Formatted Code
$T->set_block('mysample', 'mysampleblock','mysamplevariable');Ben
I'm available to customise your themes or plugins for your Geeklog CMS
11
11
Quote
All times are EST. The time is now 08:23 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content