Example #1
0
/**
 * Returns the text for a (sub)weblog.
 * 
 * The subweblog tag is a block tag, which means that it always has to 
 * have an accompanying closing subweblog tag. What's inside the tag is used to 
 * render the entries in that weblog. In fact, the contents can be seen as the 
 * template that is used for each entry. PivotX loops over the entries, and 
 * renders each one, using this 'sub template'. 
 *
 * @param array $params
 * @param string $format
 * @param object $smarty
 * @return string
 */
function smarty_weblog($params, $format, &$smarty)
{
    global $PIVOTX;
    $params = cleanParams($params);
    // This function gets called twice. Once when enter it, and once when
    // leaving the block. In the latter case we return an empty string.
    if (!isset($format)) {
        return "";
    }
    // Store the template variables, so whatever happens in the subweblog
    // can't screw up the rest of the page.
    $templatevars = $smarty->get_template_vars();
    $output = cms_tag_weblog($params, $format);
    // Restore the saved template variables..
    $smarty->_tpl_vars = $templatevars;
    return $output;
}
function snippet_subweblog($sub = "", $count = "", $order = "lasttofirst")
{
    global $Weblogs, $Current_weblog;
    if ($sub != "") {
        if (!isset($Weblogs[$Current_weblog]['sub_weblog'][$sub])) {
            debug("Subweblog \"{$sub}\" isn't defined for weblog \"{$Current_weblog}\"");
            return "<!-- error: Undefined weblogname in snippet subweblog.  -->";
        }
        if ($order != 'lasttofirst' && $order != 'firsttolast') {
            debug("Wrong optional (order) parameter in subweblog {$sub}");
            return '<!-- error in snippet subweblog: wrong optional (order) parameter -->';
        }
        $sub = "subweblog=\"{$sub}\"";
    } else {
        debug("No subweblog name given");
        return "<!-- error: Snippet subweblog needs an argument/name.  -->";
    }
    if ($count != "") {
        $count = "showme=\"{$count}\"";
    }
    $output = cms_tag_weblog("nodes=\"lower\" order=\"{$order}\" {$sub} {$count}", '');
    return $output;
}