3,035
edits
No edit summary |
|||
| Line 56: | Line 56: | ||
=== Putting it together === | === Putting it together === | ||
An example document would look something like this: | An example document would look something like this: | ||
<?php | |||
/** | |||
* FAQ page. | |||
* | |||
* @package amo | |||
* @subpackage docs | |||
* | |||
* @todo FAQ search? | |||
*/ | |||
$db->query(" | |||
SELECT | |||
`title`, | |||
`text` | |||
FROM | |||
`faq` | |||
WHERE | |||
`active` = 'YES' | |||
ORDER BY | |||
`index` ASC, | |||
`title` ASC | |||
",SQL_ALL, SQL_ASSOC); | |||
$faq = $db->record; | |||
$links = array( | |||
array( 'href' => './faq.php', | |||
'title' => 'Frequently Asked Questions', | |||
'text' => 'FAQ'), | |||
array( 'href' => './policy.php', | |||
'title' => 'Addons Policies', | |||
'text' => 'Policy') | |||
); | |||
// Send FAQ data to Smarty object. | |||
$tpl->assign( | |||
array( 'faq' => $faq, | |||
'links' => $links, | |||
'sidebar' => 'inc/nav.tpl', | |||
'content' => 'faq.tpl', | |||
'title' => 'Frequently Asked Questions') | |||
); | |||
// No need to set wrapper, since the left-nav wrapper is default. | |||
// $wrapper = 'inc/wrappers/default.tpl'; | |||
?> | |||
Here we see standard usage of $db to query data, then the $tpl->assign() function assigns local variables to the Smarty template. Here are some pointers: | Here we see standard usage of $db to query data, then the $tpl->assign() function assigns local variables to the Smarty template. Here are some pointers: | ||
| Line 115: | Line 114: | ||
faq.tpl looks like this: | faq.tpl looks like this: | ||
<h1>Frequently Asked Questions</h1> | |||
<dl> | |||
{section name=faq loop=$faq} | |||
<dt>{$faq[faq].title}</dt> | |||
<dd>{$faq[faq].text|nl2br}</dd> | |||
{/section} | |||
</dl> | |||
=== Input Filtering === | === Input Filtering === | ||
edits