21-8 ダイナミックパブリッシングプラグイン
456ページ
block.mttemplates.php
<?php
function smarty_block_mttemplates($args, $content, &$ctx, &$repeat) {
$localvars = array('template', '_templates', '_templates_counter', 'blog_id');
if (!isset($content)) {
$ctx->localize($localvars);
$args['blog_id'] = $ctx->stash('blog_id');
$templates = $ctx->mt->db()->fetch_templates($args);
$ctx->stash('_templates', $templates);
$counter = 0;
} else {
$templates = $ctx->stash('_templates');
$counter = $ctx->stash('_templates_counter');
}
if ($counter < count($templates)) {
$template = $templates[$counter];
$ctx->stash('template', $template);
$ctx->stash('_templates_counter', $counter + 1);
$repeat = true;
} else {
$ctx->restore($localvars);
$repeat = false;
}
return $content;
}
?>
458ページ
block.mtiftemplatetypeindex.php
<?php
function smarty_block_mtiftemplatetypeindex($args, $content, &$ctx, &$repeat) {
if (!isset($content)) {
$template = $ctx->stash('template');
if ($template->type == 'index') {
$flag = 1;
} else {
$flag = 0;
}
return $ctx->_hdlr_if($args, $content, $ctx, $repeat, $flag);
} else {
return $ctx->_hdlr_if($args, $content, $ctx, $repeat);
}
}
?>
459ページ
function.mttemplatename.php
<?php
function smarty_function_mttemplatename($args, &$ctx) {
$template = $ctx->stash('template');
return $template->template_name;
}
?>
460ページ
modifier.add_link.php
<?php
function smarty_modifier_add_link($text, $arg) {
return '<a href="' . $arg . '">' . $text . '</a>';
}
?>
config.yaml
name: Templates
id: Templates
description: This plugin is an example plugin.
version: 0.01
tags:
block:
Templates: $Templates::sub{}
ifTemplateTypeIndex?: $Templates::sub{}
function:
TemplateName: $Templates::sub{}