drupal
Adding a "User Comments" heading before comments list in Drupal 6
For a website I'm working on I had the need to display an Heading saying something like "User Comments" just before the user comments list and after the node comments. This can help the website user clearly understand where the node content ends and where the visitors contributions starts.
Something like the following image (In italian):
How to do it
I though it would have been a complex task: I thought it would have required to override some theming function and hacking deeply into Drupal.
Fortunately it wasn't complex at all. In Drupal 6 there are template files already available to be overriden for a lot of Drupal output.
In this case there is a file called comment-wrapper.tpl.php which we can override in our theme. This file is a wrapper for all the content generated by the comment module (comment lists, comment adding form, etc.).
So we can just place in a file called comment-wrapper.tpl.php within our theme directory the following code:
<?php
// from $Id: comment-wrapper.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
// modified by Fabio Varesano for ermannofalco.com
/**
* @file comment-wrapper.tpl.php
* Default theme implementation to wrap comments.
*
* Available variables:
* - $content: All comments for a given page. Also contains sorting controls
* and comment forms if the site is configured for it.
*
* The following variables are provided for contextual information.
* - $node: Node object the comments are attached to.
* The constants below the variables show the possible values and should be
* used for comparison.
* - $display_mode
* - COMMENT_MODE_FLAT_COLLAPSED
* - COMMENT_MODE_FLAT_EXPANDED
* - COMMENT_MODE_THREADED_COLLAPSED
* - COMMENT_MODE_THREADED_EXPANDED
* - $display_order
* - COMMENT_ORDER_NEWEST_FIRST
* - COMMENT_ORDER_OLDEST_FIRST
* - $comment_controls_state
* - COMMENT_CONTROLS_ABOVE
* - COMMENT_CONTROLS_BELOW
* - COMMENT_CONTROLS_ABOVE_BELOW
* - COMMENT_CONTROLS_HIDDEN
*
* @see template_preprocess_comment_wrapper()
* @see theme_comment_wrapper()
*/
?>
<div id="comments">
<?php if($node->comment_count){ print '<h3 class="comments-intro">' . t("User Comments") . "</h3>"; } ?>
<?php print $content; ?>
</div>
With the same approach we could add a link to the comment creation form (just adding a link to #comment-form) or adding a disclaimer. Actually with this approach there are lot of possible usage of modifying comment output.
What do you think about my approach? Did you find it useful? Do you have problems implementing it? Feel free to leave me a comment and let me know!
- fabio's blog
- Add new comment
- Read more
- 34 reads
Are you using Mollom on Drupal? Then do not upgrade to 6.x-1.11
Some days ago I updated the mollom Drupal module version 1.10 installed on this site with the new version 1.11.
For those unfamiliar with Drupal, Mollom is a service which analize comments, posts, etc to check for spam and blocks suspicious content. Mollom has been founded by Dries Buytaert and Benjamin Schrauwen. Dries is the project lead of Drupal and CTO at Acquia. So, yes: Mollom is high quality stuff created and maintained by top people on the Drupal ecosystem.
Unfortunately, as soon as I updated the mollom module I noticed that something was wrong: the configurations of the protected forms where missing after the update. All my forms where unprotected.
As soon as I noticed this I opened a bug report, but today I had the time to have a deep look on this and I found that it's due to a bad bug in the update path from 1.10 to 1.11. I reported it to Dries and Dave and they agreed on the gravity of this bug.
This is pretty bad as it looses the protected forms configuration of 1.10: this results in leaving all the forms unprotected against spam. As Mollom is installed in high profile Drupal websites (Sony, Adobe, LinuxJournal, Warner Bros Records, Netlog, NBC, etc) the consequences of this bug can be pretty bad.
So, if you are a Drupal and Mollom user stay away from 1.11 and wait till 1.12 which will fix this issue. Patches are already available and a new release should came soon.
- fabio's blog
- Add new comment
- Read more
- 206 reads
Displaying last updated or changed date on a Drupal node
Drupal 5.x and 6.x default behavior concerning the visualization of post dates it's pretty simple.
It just display the date when the post has been created. Something like:
Submitted by fabio on Mon, 2009-07-06 17:05.
Well, that's nothing wrong with this if you are used to post and then forget about what you posted. But if you usually keep your posts updated (eg when you created a guide for a software which has been upgraded) then the created date it's pretty useless as no information is displayed on the last update (changes) date.
With the recent Drupal 6 upgrade I completed on this website, I did some little theme tweaks to improve posts date visualization.
Using the following code you will be able to obtain something like:
Last updated on Thu, 2009-03-05 02:15. Originally submitted by fabio on 2007-02-19 17:32.
- fabio's blog
- 4 comments
- Read more
- 2261 reads
Running Drupal 6
I just completed upgrading this website to Drupal 6.
The procedure went fine, even if I had to install some "still in development" modules. Notably the image module still doesn't have a stable 6.x version.
As the theme I'm using is a custom one created by myself, I also needed to convert it from 5.x to 6.x. The conversion has been pretty simple, just some minor changes as my theme is pretty simple.
With the theme upgrade I also did some minor tweaks to the theme. I revised the header making it a little bit more usable: I'm interested in hearing what you think about it.
So.. it seems that everything went fine. Anyway, if you find any problem with this site, please let me know. Thanks!
- fabio's blog
- Add new comment
- Read more
- 688 reads
New life to CSS module: release candidates for Drupal 5.x and 6.x out
Thanks to the help of jchan, christopher_skauss, whispero and the free time of Christmas Holidays I've been finally able to create two release candidates for Drupal CSS module.
The CSS module is a Drupal module which add inline CSS editing to Drupal nodes. This is pretty useful for Drupal power users / designers which are able to create CSS based complex node designs.
- fabio's blog
- 4 comments
- Read more
- 1197 reads
How I discovered a critical Drupal 5.13 PHP incopatibility
Maybe you already know that, in some countries, the number 13 is associated with bad luck and some people are really frightened of it.
Personally I don't care much of all this stuff.. I don't believe such things.
But seems that Drupal version 5.13 had pretty an unlucky life given that it had been out just for a couple of days and later replaced by the new version 5.14.
- fabio's blog
- Add new comment
- Read more
- 980 reads
Drupal: how to clear the filter cache
A filter is a Drupal feature, usually implemented by some contributed modules, which substitutes parts of a node text with some other text.
Eg: if you use the Path filter module you can insert links like:
<a href="internal:node/25">hello!</a>
and the string internal:node/25 will be substituted by something like http://www.example.com/node/25 where www.example.com is your website url.
- fabio's blog
- Add new comment
- Read more
- 3066 reads
Drupal 6: get parent nid of a book child page
I had to get the parent nid of a book child page for a website which already uses Drupal 6.
Seems that the book module logic has changed deeply between version 5. The new stack implementation of the parent-child relationships is pretty complex, at least for me. I have to say that I did not studied it a lot thought.
So.. this is the code to do that:
<?php
if(isset($node->book)) { // book page
$parent = book_link_load($node->book['plid']);
$pid = $parent['nid'];
}
?>
Hope this helps.
- fabio's blog
- 3 comments
- 3184 reads
A firefox search plugin for Drupal 6 apis at api.drupal.org
Some time ago I created a api.drupal.org firefox search plugin for Drupal 5.x and submitted it to the Mycroft Project for indexing.
Well, I've been requested to do the same for Drupal 6 Apis.
So.. I did it. There is now a Drupal 6 Apis search plugin available at Mycroft.
You can get it from the list of search plugins I created.
- fabio's blog
- 3 comments
- Read more
- 1769 reads
Disable related videos on a embedded Youtube player
Youtube recently added a new feature to the video player used to embed Youtube videos on other website.
The new default player, once the video completes playing, will display a list of related videos.
While this feature could be useful for some users it is probably not wanted on Youtube video aggregation websites.
Fortunately it's possible to disable related videos.
Let's see how.
- fabio's blog
- 60 comments
- Read more
- 37469 reads






Recent comments
3 hours 21 min ago
12 hours 13 min ago
1 day 7 hours ago
1 day 12 hours ago
1 day 13 hours ago
1 day 13 hours ago
1 day 14 hours ago
1 day 20 hours ago
2 days 5 hours ago
2 days 9 hours ago