Finally got around to tackling a bug on the site. As I've said before the site is not 100%. In part this whole thing is an excercise in learning PHP development as well as some movable type blogging.
I've done a bit of monkeying with the default template - and I've mused on how to include some PHP into the templates and allow for some added functionality. Today I put some of that into practice to take care of a bug on the site.
I changed the template to show all comments right under the original news item. I wanted a way to seperate the comments from the original post so I added a heading that said "comments". The problem was that this "comments" heading would show up whether or not there was actually any comments.
To fix this it was a matter of including a simple conditional statement in the template using a bit of PHP. It went something like this.
<?PHP if(<$MTEntryCommentCount$> > 0) echo 'Comments
'?>
How does it work: The MT template tag is processed as the page is being built. The page output by the template includes the PHP code. The line is evaluated when the page is requested - and the 'comment' heading is either shown or not depending on whether there are any comments.
Is there a better way? Let me know. I'm sure there is. But this was a quick and dirty way to take care of something that was bugging me.
andre
Posted by andre at March 1, 2004 02:16 AM