Exemplo n.º 1
0
<?php

require_once "page-yatt.inc.php";
$dir = new YATT();
$dir->load("{$template_dir}/directory.yatt");
$sth = db_query("select fid,name,shortname from f_forums where options like '%Searchable%' order by name");
for ($i = 0; $row = $sth->fetch(); $i++) {
    $dir->set("r", $i & 1);
    $fid = $row['fid'];
    /* should only count active and off-topic, but its too slow */
    try {
        $row2 = db_query_first("select count(*) from f_messages{$fid}");
        $count = $row2 ? $row2[0] : NULL;
    } catch (PDOException $e) {
        $count = NULL;
    }
    $dir->set("count", $count);
    $dir->set("row", $row);
    $dir->parse("dir.row");
}
$sth->closeCursor();
$dir->parse("dir");
print generate_page('Directory', $dir->output());
Exemplo n.º 2
0
<?php

require_once 'YATT.class.php';
$n = new YATT();
$n->load("example.yatt");
# set a variable
$n->set('CRACK', 'eat me');
# or like this
$n->set(array("FOO" => "something else", "BAR" => "barorific!"));
# Variable substitution is recursive, see how this works in the template
$n->set('FNORK', 'baz');
$n->set('CORK_baz', 'shout off and die');
# Parse a single block of text
$n->parse('faz.test');
# Maybe build a table
foreach (array("ONE", "TWO", "THREE") as $value) {
    $n->set('ROW_NAME', $value);
    $n->parse('faz.table.row');
}
$n->parse('faz.table');
# Comment this out and look at the output.
# Notice that everything *but* what is in faz is displayed.
# Only nodes that you parse() actually display things.
$n->parse('faz');
# print the output for everything.
# You could also tell it where to start, like output('faz.table')
# to only print out stuff from table.
print "--------------------------------------------------------------\n";
print "Output of the template:\n";
print "--------------------------------------------------------------\n";
print $n->output();