Jun 29 2004

BlogTimes fixed

Published by foxfair at 2:29 pm under Computer

You may find out there is one more “blogtimes” picture at the top-right corner recently, I have already adapted Nilesh’s BlogTimes plugin into this site. This is a funny plugin, let the author(and readers) know how many posts you wrote in +hours of days every month+. Unfortunately, there is one limitation: You can NOT give a customized filename like demo part in Nilesh’s page, becuase MT doesn’t support nested tag attribution assignment. How do I solve this problem?

Answer: 1. Do a little hack. Install Kalsey’s Expressions plugin into blog/extlib/MTPlugins (create this directory if it doesn’t exist). 2. Patch blogtimes.pl like this:

— blogtimes.pl.orig Tue Jun 29 13:42:33 2004 +++ blogtimes.pl Tue Jun 29 13:54:52 2004 @@ -33,6 +33,7 @@ use MT::Template::Context; use MT::Util qw(days_in offset_time); use GD; +use MTPlugins::Expressions; MT::Template::Context->add_container_tag(BlogTimes => \&BlogTimes); MT::Template::Context->add_tag(BlogTimesWidth => \&BlogTimesWidth); @@ -43,6 +44,11 @@ sub BlogTimes { my ($ctx, $args) = @_; + + my $tokens = $ctx->stash(’tokens’); + my $builder = $ctx->stash(’builder’); + $args = MTPlugins::Expressions::process($ctx, $args); + # Default Values my $chart_type = $args->{style} || ‘bar’; my $blog = $ctx->stash(’blog’); @@ -134,8 +140,8 @@ print CHART $img->png; close CHART; - my $tokens = $ctx->stash(’tokens’); - my $builder = $ctx->stash(’builder’); +# my $tokens = $ctx->stash(’tokens’); +# my $builder = $ctx->stash(’builder’); local $ctx->{__stash}{BlogTimesWidth} = $scale_width; local $ctx->{__stash}{BlogTimesHeight} = $scale_height;
  1. Call your blogtimes template, note that change the name part:

<MTBlogTimes textcolor=”#FFFFFF” linecolor=”#cccccc” width=”220″ height=”14″ save_dir=”images” show_text=”on” name=“[MTDate format='blogtimes-%Y-%b']“>

Now it gives a blogtimes file named “blogtimes-2004-Jun.png” as you see, happy ending. Thank you Nilesh and Kalsey to bring these useful plugins to us!

Comments RSS

Leave a Reply