The Hickensian
4.10.05
Textpattern Notes: Comments revisited
In Textpattern notes parts 2, and 4 I explained how to hack TXP’s comments system to acheive certain effects. A lot has changed since then (especially with v4.0), and I need to update the methods. I’m now running TXP with no hacks whatsoever, and that’s a very good feeling™.
So lets run through those old hacks:
Step 1,4 & 5 – Changing the preview method, and integrating live Textile previews
I didn’t like having to preview the comment on a separate page (although this is a good spam-saving measure). I wanted to give users a live preview and allow them to submit their comment straight away.
These steps are now all combined within one plugin: nhn_livecommentpreview
It’s worth pointing out, that even with this safety feature removed, I only get comment spam at the rate of 1 every couple of months.
Step 2 – changing the comments to display as <div>’s rather than <li>’s
Simple. Go to Admin > Preferences, and under the ‘Comments’ section. click no to “Present comments as a numbered list?”. You’re now free to wrap your comment markup in whatever takes your fancy.
Step 3 – alternating background colours and sequential numbering
These steps can still be done with php, but for an easier life, I use ajw_comment_num (Allows for outputting current comment number) and ajw_comment_alt 0.3 (Alternates output based on even- or odd-numbered comments) by Andrew Waer
Step 6 – Adding an article link to the notification email
Now in TXP as of 4.01!
See how much easier it all is? Thanks to all the TXP and plugin developers for making my life so much easier.
With the next Textpattern notes, I’m going to look at some of the new tag goodness, especially the new conditional tags…
40 comments


Download our vCard
RSS Feed
Comments | RSS
Dave Simon said 1369 days ago:
Whew –The power of plug-ins. I may actually have comments enabled on my site before too long now that I know all this.
Thanks Jon!
Andrew said 1369 days ago:
And, for those who leave Textpattern’s default comment preview functionality intact, I just released another plugin (ajw_if_preview) that allows for conditional output during comment preview.neil said 1369 days ago:
I’m currently evaluating Textpattern as a replacement for a client’s site that currently runs Movable Type. It definitely has matured a lot since it first came out. The biggest issue I have is that the documentation stinks – I know there’s TextBook, but a half-filled wiki does not make for good documentation, especially when one is learning the platform…Still, compared to WordPress I think Textpattern has the upper hand. Thanks for these articles, Jon – they’re very useful!
Ben Ward said 1368 days ago:
Thanks John, your little tid-bits on TextPattern always have a certain real-world simplicity that inevitably results in me wanting to go play with more of TextPattern’s nice bits.I’ve finally started using it, having not had a project for a while. Moving my brother’s band’s site over from a simple content-pulling script I wrote in an hour to something as advanced as TxP has been quite an experience but it’s going suprisingly quickly. I’m very impresed with the platform, though I think I’m always going to be pleading for more flexibility in the template tags.
…I digress. Despite my better, controlled side demanding that I not go overboard with plugins and so forth, I have a feeling that I may ned to play with the comment presentation toys.
pketh said 1368 days ago:
conditionals are too hardcore for me, so if you ever write about em be sure to keep it simple :Doliver taylor said 1368 days ago:
I looked at TXP for a while and even almost used it on a cliet’s site, that is until I found out I couldn’t mix textile and html code when posting… seems like a glaring omission to me (not being able to do definition lists of any kind is annoying).Am I missing something?
Jon Hicks said 1368 days ago:
Oliver – you’re missing something here. I mix Textile and HTML just fine.Andrea said 1368 days ago:
Oooh—how did you get the comment form to remember me and not display the name/email/url inputs? This is a nice touch. Is this part of the plugins you mentioned above, or another trick?Jon Hicks said 1368 days ago:
Andrea, I’m using the if_cookie plugin to detect the presence of comment form cookies, and hiding the name/email/URL fields with display:none.Andrea said 1368 days ago:
Ahh, thanks! Very nice. Makes your comment form seem very friendly and personable (if that’s possible…).mourner said 1368 days ago:
Jon, you are a wizard! Thanks for such a useful article.Peter said 1368 days ago:
Is it too off topic to ask how you mix snippets of HTML in with Textile?I’m building my first site for a client with Textpattern, and while you can find most things either intuitively or by a lot of searching through forums (fora?!) I still haven’t found out how to wrap a block of Textile text with a div (other than in the Form itself, which isn’t going to hack it in this particular case).
Anyone able to point me in the right direction?!
Anyway, I’m pretty impressed with Textpattern I must say, though the documentation is confusing as anything (clean vs messy URLs for example!)
Jon Hicks said 1368 days ago:
Not off-topic at all. I just do it – TXP supports it by default. Is it not working for you?Peter said 1368 days ago:
Some HTML-type content I just turn off Textile, obviously.But embedding HTML in Textile – I tried something like [code]...[/code] I think (I forget – tried lots!) but to no avail. I am obviously missing the basics here Jon – finding how to do things in the documentation isn’t always easy!
Any hint appreciated!
Jakob Heuser said 1368 days ago:
Well I’ll be. Doesn’t that make the whole lot simpler?Peter: there’s some interesting things with code/pre you need to do sometimes to make code snippets work. A lot of people use the glx_code plugin for placing code into their documents. (However, it requires an external file.)
If you want to use GeSHi as a syntax highlighter, there is also some core textile tweaks you have to make. Kelvin has a great tutorial on fixing textile’s notextile tag which may provide a good starting point if you need more than code/pre can offer. You can also find his plugin at his project page
This is a wonderful resource on how to make the notextile tag work (still has a little annoying bug as of 4.0) that can be fixed in about 20 min work. With it, you can drop html right into the template a txp tag block which will render your inline code. You can see a trimmed down version of the plugin used in this entry for the syntax blocks.
Alex said 1368 days ago:
Jon, regarding Step 2:“Step 2 – changing the comments to display as div’s rather than li’s”
It’s not necessary to change the preference – that’s simply there for backwards compatibility. Regardless of what the preference is, you can override the comment wrapping by editing your txp:comments tag:
[txp:comments wraptag=”div” class=”list” break=”div” breakclass=”comment” /]
..etc. wraptag/class wraps the entire list (‘ol’ by default), break/breakclass is for each individual comment (‘li’ by default).
Alex said 1368 days ago:
btw, you’ll find the comment tags documented in Textbook:http://textpattern.net/wiki/index.php?title=Alphabetical_Tag_Listing
Lea said 1368 days ago:
This is great! Making life easier one upgrade at a time. :-)neverything said 1368 days ago:
Thank you Jon for this great article. Most of them plugins I started using right after reading this. Thanks a lot.Tomas Jogin said 1368 days ago:
Why use divs instead of lis at all? I don’t need to tell you that lis with list-style:none, zero margins and padding, and display:block, essentially are divs? So why?Jon Hicks said 1368 days ago:
While I want numbered comments, I need the flexibility of stylng and markup. To create these rounded boxes needs tags that aren’t valid within a list.Lowell Wood said 1368 days ago:
This is way off topic, but its important to me. I think it might could just by my computer (new Powerbook running Firefox) but all of the png gravatars are displayed at grey squares. its not a png problem though, because the contact png displays just fine.Any one else having the same problem?
Also, Jon; when you type enough in the comment, the preview doesnt push down the [new] footer (which i happen to like alot).
Jon Hicks said 1368 days ago:
Lowell – not sure, I’d assumed that meant that gravatar.com was down, but it affects some and not others.Also, what browser/platform are you using? I can’t get the footer problem here, but I’d like to solve it.
Steve said 1368 days ago:
Re: Gravatars (whatever they are!)I’m viewing using Safari 2.0.1 on a PowerMac G5, in good daylight wearing blue underpants, and I see a mixture of Grey boxes, Gravatars and nothings.
Hope this helps in some way.
Lowell Wood said 1367 days ago:
Jon; I am running Mac OS X Tiger and Firefox 1.0.6 (I’m afraid of camino and upgrading to a newer version of firefox because of my extensions).Good luck sorting all of this out.
John Y. said 1367 days ago:
Jon, thanks for the update!Alberto said 1367 days ago:
Hi Jon,after reading some articles about TXP on your wonderful site I’m evaluating this CMS for my personal site.
In fact TXP is really cool but I have some doubts about code editing.
When I build a site I would like to use my code editor of choice but since TXP code is stored in a database I have to use its tiny windows to build page template and forms (as for the css I created a real file so there is no problem). Please tell me: how do you code page templates and forms in TXP? Do you have some tricks to suggest?
Many thanks
Lowell Wood said 1367 days ago:
Alberto; I use TXP and I use my code/text editor to construct every part of my site, and then i put it in the templates or forms (depending on where it needs to be) and switch out where i put placeholders for actual functions TXP can do.For example, i would replace “Title” with < txp:title />.
As for a more direct answer to your question, i think it is necessary to continue to keep using a code/text editor.
Cody Lindley said 1365 days ago:
Jon – have you recieved any comment span after using the nhn_livecommentpreview plugin. I get refer spam all the time, but for the first time after installing this plugin I actually received comment spam.Jeff Khonsary said 1365 days ago:
Writting code in TXP:template is a bit of a drag, but you can customize the template input form without too much trouble. Just fiddle with the textpattern.css file in the textpattern subdirectory. I have mine set to output monospace 9px type in a bigger input window. I also seem to remember that there was a plugin for changing the size of the input window..A script that switched text within the input box back and forth between textpattern and a text editor would be nifty though.. A way of aligning tabbed includes would be the ultimate though.
Jon Hicks said 1365 days ago:
_ “A script that switched text within the input box back and forth between textpattern and a text editor would be nifty though.. A way of aligning tabbed includes would be the ultimate though.” _Well, if you use Textmate it’s already there! Select the text, apple-escape, and the selection opens in Textmate. Press save and it updates the text in the textarea! Or use Omniweb with its zoomed text editor, or use Saft with Safari and open the text in BBEdit or SubEthaEdit.
It’s never been a problem for me. I use external css (not the inbuilt TXP method, and editing the templates with the methods above works well.
Jeff Khonsary said 1364 days ago:
Jon, I will look into those options, thanks. Maybe I will have to try my hand at rigging an automator script to switch text between Firefox/TXP and skEdit.walter Piovesan said 1361 days ago:
jon – wherein do you add the “display=none” to hide the cookies. In thecomments_display form? And i like you get avatr trick ;-)eric said 1361 days ago:
I just switched to textpattern myself – right now it’s running my portfolio, but I’ll eventually bring back a journal of sorts. Having worked with it, I’m a convert (I think!) to the mentality of how it arranges things. Jon, your implementation is great, and the plugins all seem to be working very well.I do have one question – your archives don’t have dates listed anywhere. Is there a reason behind that?
Jon Hicks said 1361 days ago:
_ “I do have one question – your archives don’t have dates listed anywhere. Is there a reason behind that?” _Hey Eric – what do you think those numbers are for? ;o)
– :jon – wherein do you add the “display=none†to hide the cookies. In thecomments_display form? And i like you get avatr trick ;-): _
You have to hide the name, email, and URL fields. More explanation to follow…
eric said 1360 days ago:
haha, well, I see dates in the archives, sure. If I navigated to an article via the archives or front page I’d know, but I caught this particular one from a del.icio.us link. Since I was linked straight here, I had to base the article’s age on the comment ‘x days ago’. :D Just causes a little confusion is all, no real issue.Jon Hicks said 1360 days ago:
Ah! Sorry! I see what you mean!I recently rejigged my article forms, and left off the posted date. I’ll sort that out soon!
Puzzled said 1357 days ago:
Is there a way to get Textpattern to really validate an email address?Robin Wright said 1352 days ago:
@PuzzledWhat do you mean by validating? To check if the email address is real? Or validate if this is the persons real email address?
That would not be a easy job todo.
Well maybe one thing you can do is to send them a confirmation message that they need to access. (e.g. http://foo.bar/section/message?auth=FS134sdwr34)
But I think you will loose the dynamic structure of comments.
walter Piovesan said 1350 days ago:
>You have to hide the name, email, and URL fields. More explanation to >follow…if you have a moment i would like how to proceed with this issue,,, thx!