Customize your MT admin page – comments

We had some problems with comment spam recently so we wanted to see more comments at the same time…

We could have just made a new plugin, or found one already written, and used it in a new index, but then we’d have to rebuild the thing every time we needed to find spam.

So, I went into our MT installation and changed it directly to show the last 25 comments instead of the last 5.

  • MT_HOME/tmpl/cms (for example /usr/local/apache/cgi-bin/mt/tmpl/cms )
    is where the templates are.

  • The one which we want is menu.tmpl which defines COMMENT_LOOP.

  • They use a templating language defined by Template.pm which lives at
    MT_HOME/extlib/HTML (for example /usr/local/apache/cgi-bin/mt/extlib/HTML ). This module is very well commented, type

    perldoc Template

    to read it.

  • now we want to change the number of times the COMMENT_LOOP iterates-
    kind of a pain in the ass, since it iterates over an array, and so it will be the length of the array and not defined in our template at all!

  • the library that builds this is called
    MT_HOME/lib/MT/App/CMS.pm
    ( for example
    /usr/local/apache/cgi-bin/mt/lib/MT/App/CMS.pm ).

  • the array in question is called @c_data and somewhat disturbingly has a hard coded length:
    $iter = MT::Comment->load_iter({ blog_id => $blog_id },
            { 'sort' => 'created_on',
              direction => 'descend',
              limit => 5 });
        my @c_data;

    See that 5? that’s our puppy!

Leave a Reply