function showTemplate($tpl, $code = null)
The showTemplate function takes each returned item from your Pod class and wraps them in your template of choice.
<?php
// Initialize the pod
$pods = new Pod('pod_name');
// Find items in that pod
$pods->findRecords('id DESC', 15);
// Use the template named "item_listing" for each item found
echo $pods->showTemplate('item_listing');
?>
Parameters
| Parameter | Type | Details |
| $tpl |
STRING |
the name of the template you want to use |
| $code |
STRING |
(optional) use custom code instead of an existing template |
Examples
Add Pod Items
You have a pod called “event” with the following items:
| id | name | date |
| 1 | First Event | 2009-06-02 10:30:00 |
| 2 | Second Event | 2008-02-12 18:00:00 |
| 3 | Third Event | 2008-05-20 04:30:00 |
Create Pod Template
You have a template called "event_list" with the following code:
Setup Pod Page
In a new Pod Page (called "events", for example), you can display this item listing. For this example, we'll sort the items in descending order by date.
<?php
$pods = new Pod('event');
$pods->findRecords('date DESC', 25);
echo $pods->showTemplate('event_list');
?>
And the Final Output...