New ExpressionEngine extension: Scroll to new comment
- Categories:
- ExpressionEngine
- Tags:
- comment, css, expressionengine, scroll
- Published:
- 8:44pm on Friday 2nd January, 2009
While developing this incarnation of The Watchmaker Project I came across one glaring omission in my new CMS of choice, the awesome ExpressionEngine.
Sure, the guys at EllisLab like to tell us how flexible their application is - how it can run multiple sites, online shops, enormous government portals - but for something that started off as a blog engine, why doesn’t it offer the ability to return to the comment you just added? It was frustrating, so I dug into the core code to see what could be done. Luckily there was a hook in just the right place for a shiny new extension. And here it is.
Scroll To Comment
Like all ExpressionEngine extensions, the steps to get this up and running are pretty simple:
- Download and unzip the files from the package
- Place the
ext.scroll_to_comment.phpextension file in the/system/extensionsfolder of your EE install - Place the
lang.scroll_to_comment.phplanguage pack in the/system/languages/englishfolder - Visit your EE Control Panel, and navigate to Admin > Utilities > Extensions Manager
- Enable the new extension
- Visit the ‘Settings’ page to change the prefix setting if necessary
- You’re good to go!
A few quick words on CSS id attributes
As noted a while back by Veerle, if you want your code to be 100% W3C valid you can’t start a CSS id attribute with a number. That is why this extension provides the option of including a prefix to all comment ids, which you will have to match up with your (X)HTML markup - here’s mine:
{exp:comment:entries sort=“asc”}
<li id=“c_{comment_id}”>
<h4><strong>{url_as_author}</strong> at »
{comment_date format="%g:%i%a"} on {comment_date »
format=”%j%S %F, %Y”} <a href=”#c_{comment_id}”> »
#</a></h4>
<blockquote>
{comment}
</blockquote>
</li>
{/exp:comment:entries}
All the comments on my site are prefixed with “c_” - and, as long as I also use that in my extension settings, every time anyone submits a comment the page will reload displaying their new comment.
What is GitHub? GitHub is a web application that uses the version control software Git to allow its members to manage their code online. I am hosting the files for this article there so that any bugfixes or improvements I make can be found in one central location.

I'd love to hear what you think - please use the form below to leave your comments. Some HTML is permitted:
Commenting is not available in this weblog entry.b,i,em,del,ins,strong,pre,code,blockquote,abbr. URLs or email addresses will be automatically converted into links.Nathan Pitman at 9:24pm on 3rd January, 2009 #
Luke Dorny at 7:02am on 15th January, 2009 #
Indranil at 2:42pm on 15th January, 2009 #
John Faulds at 2:48am on 18th January, 2009 #
Front at 5:27pm on 6th May, 2009 #
Craig Allen at 3:20am on 22nd May, 2009 #
Matthew Pennell at 7:02am on 23rd May, 2009 #
Laisvunas at 8:03am on 6th June, 2009 #
Markus Stolpmann at 10:29am on 6th June, 2009 #
Matthew Pennell at 1:17pm on 6th June, 2009 #
Laisvunas at 7:37am on 7th June, 2009 #
Husker at 7:10pm on 25th June, 2009 #
Laisvunas at 9:26am on 23rd August, 2009 #
Jules van Schaijik at 1:50am on 10th November, 2009 #
Bedava Oyun indir at 12:21am on 17th December, 2009 #
Pasquale Abate at 6:48pm on 21st June, 2010 #