Put comments anywhere on an article page
A.K.A. “How to seperate articles from discussion”
Seriously though, this is a dead easy hack to Textpattern that will let you have your comments anywhere on an article page—not just tacked onto the bottom of the text like the default behaviour. See this site for an example—the comments appear in a completely different part of the page (in the code, anyway).
There are two main pieces to this puzzle. The hack and the plugin. First, the hack.
Easiest Hack Ever.
Find the following code in publish.php, at around line 387 – it’s at the end of the doArticle() function.
Now just comment it out. Or delete it, if it has offended your mother. That’s it! The difficult bit is out’ve the way! Take 5, then come back for the challenge that is the rest of this howto…
Plugin A-Go-Go
Here’s the code for the plugin:
Install that into Textpattern. This will give you a new tag <txp:post_comments />. Guess what it does? Go on, guess! That’s right, it outputs the comments and comment form!
Finishing Up.
All that’s left to do, is to place this tag on the page. To do this, pick a spot – any spot will do – and add the tag. You’ll want to surround it with <txp:if_individual_article> tag so that it’s only displayed on an article page. If you don’t, you’ll most likely get a load of errors.
There, that was easy, wasn’t it? It didn’t take long and you’ve just opened up a whole load of layout possibilities that you didn’t have before!









If there is a comment form at the Information URL, you may want to leave your comments/questions there for quicker feedback. Otherwise, comment away:
Commented (6)
Rob(Wilshire) talked me through how to compile a plugin (used zem_tpl).
Chris may decide he wants to compile the plugin himself and make that available at some point… meanwhile, i hope it’s okay that i’ve made my compiled version of his code available..
i’ve called it cml_post_comments
Also, why would you want visitor comments in the middle of the page?
Basically the idea is that you can opt to put the comments anywhere that you want. if you want them on the bottom, that’s fine too. i think there’s a new feature being built into textpattern that will allow you to put the tag to output comments anywhere on the page.
I’d like to use this facility, but where has the plugin code gone? There is now just a blank space and the info URL is dead. Has it been removed? Was it buggy?
Subscribe to this article's comments RSS feed. [ ? ] View Recent Comments across the site. Get a Gravatar.
Would you care to write a comment?