############################################################################### # MTCategoryDescription - A Plugin for Moveable Type # http://blog.boundless-ocean.ne.jp/ # # Release 1.0 # June 02, 2004 # --------------------------------------------------------------------------- # This software is provided as-is. # You may use it for commercial or personal use. # If you distribute it, please keep this notice intact. # # Copyright(C) 2004 BoundlessOcean All Rights Reserved. # --------------------------------------------------------------------------- ############################################################################### package MT::Plugins::CategoryDescription; use strict; use MT::Template::Context; MT::Template::Context->add_tag('CategoryDescription' => sub { &get_description; }); MT::Template::Context->add_container_tag('CategoryIfDescription' => sub { &check_description; }); sub get_description { my ($ctx, $args, $cond) = @_; my $e = $ctx->stash('entry'); my $cat = $e?$e->category:($ctx->stash('category') || $ctx->stash('archive_category')); if (!defined $cat) { return ''; } return $cat->description; } sub check_description { my ($ctx, $args, $cond) = @_; my $e = $ctx->stash('entry'); my $cat = $e?$e->category:($ctx->stash('category') || $ctx->stash('archive_category')); if (!defined $cat) { return ''; } my $desc = $cat->description; if ($desc) { return MT::Template::Context::_hdlr_pass_tokens($ctx, $args, $cond); } else { return ''; } } 1;