Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

188 lines (111 sloc) 8.315 kb
<!doctype html>
<!--[if lt IE 9]> <html class="no-js oldie" lang="en"> <![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Theme nodes with closed comments in Drupal 6 | Divya Manian</title>
<meta name="author" content="Divya Manian">
<meta name="description" content="I use Comment Closer to close comments on old posts to reduce spam on my blog. I wanted visitors to know immediately if a post was no longer &hellip;">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="">
<link href="/stylesheets/screen.css" rel="stylesheet">
<link href="" rel="alternate" title="Subscribe" type="application/atom+xml">
<link href="" rel="alternate" title="Subscribe to Web Development updates" type="application/atom+xml">
<body >
<div class="container">
<div class="content">
<header role="banner"> <h1><a href="/">Divya Manian</a></h1>
<h2><a class="twitter" href="">twitter</a> <a class="rss" href="">RSS Feed</a> <a class="youtube" href="">Youtube Channel</a> <a class="github" href="">Github</a></h2>
<nav class="sitenav"><a href="/">Home</a>
<a href="/archives">Archives</a>
<a href="/about.html">About</a>
<nav class="article">
<a class="previous" href="/book-reviews-for-jan-2010-part-1.html" title="Book Reviews for Jan 2010 – Part 1">&#x276C;</a>
<a class="next" href="/book-reviews-for-jan-2010-part-2.html" title="Book Reviews for Jan 2010 – Part 2">&#x276D;</a>
<time datetime="2010-01-10T00:00:00+05:30" pubdate><span class='month'>Jan</span> <span class='day'>10</span> <span class='year'>2010</span></time>
<h1 class="entry-title"><a href="/theme-nodes-with-closed-comments-in-drupal-6.html">Theme nodes with closed comments in Drupal 6</a></h1>
<div class="entry-content"><p>I use <a href="">Comment Closer</a> to close comments on old posts to reduce spam on my blog. I wanted visitors to know immediately if a post was no longer accepting comments, and give them alternative means of contacting me about the post. You can see it in action in these two old posts: <a href="">post with comments</a>, <a href="">post with no comment</a>. Here is how I did this in Drupal 6:</p>
<h3>Posts with no comment</h3>
<p>Use the following in <code>node.tpl.php</code> file in your Drupal theme: </p>
&lt;?php if (($page != 0) &amp;&amp; isset($node-&gt;comment_count) &amp;&amp; $node-&gt;comment_count &lt; 1) { ?&gt;
&lt;?php if($node-&gt;comment == 0 || $node-&gt;comment == 1) { ?&gt;
// Enter HTML content you want to render for posts
// that are closed with no comment.
&lt;?php else { ?&gt;
// Enter HTML content you want to render for posts
// that are open for new comments but have none.
&lt;?php }
} ?&gt; </code></pre>
<h3>Posts with comments</h3>
<p>In <code>comment-wrapper.tpl.php</code>, use the following: </p>
&lt;?php if($node-&gt;comment == 0 || $node-&gt;comment == 1) { ?&gt;
// Enter HTML content you want to render to inform the visitor
// that new comments are no longer accepted.
&lt;?php } ?&gt; </code></pre>
<p>We need to edit both <code>comment-wrapper.tpl.php</code> and <code>node.tpl.php</code> as <code>comment-wrapper.tpl.php</code> (despite its name) will NOT be rendered if a node has no comments. </p>
<p class="meta">This post was posted by
<a href="/about.html">Divya Manian</a>
<time datetime="2010-01-10T00:00:00+05:30" pubdate><span class='month'>Jan</span> <span class='day'>10</span> <span class='year'>2010</span></time> in
<span class="categories">
<a class='category' href='/categories/web-development/'>Web Development</a>
. If you would like to update this post, <a href="">please send a pull request</a>.
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>
<aside id="articles">
<p><img class="avatar" src="" height=48> <a href="">Divya Manian</a> lives in SF. <a href="/about.html">More about me ❭</a></p>
<h2>Posts on Web Development</h2>
<ul><li><a href="/diversity-in-conferences.html">Diversity in Conferences</a></li><li><a href="/using-decimal-percentage-values-in-responsive-design.html">Using decimal percentage values in responsive design</a></li><li><a href="/using-background-clip-for-text-with-css-fallback.html">Using background clip for text with CSS fallback</a></li><li><a href="/markup-free-icon-fonts-with-unicode-range.html">Markup-free icon fonts using unicode-range</a></li><li><a href="/jscamp-css-next.html">JSCamp: CSS Next</a></li><li><a href="/some-updates.html">Some Updates</a></li><li><a href="/css-object-model.html">CSS Object Model</a></li><li><a href="/fake-bolding-of-web-fonts.html">Fake Bolding of Web Fonts</a></li><li><a href="/html5please-api.html">Html5please API</a></li><li><a href="/html5please.html">html5please</a></li><li><a href="/mustache.html">mustache, hogan, handlebars</a></li><li><a href="/redesign-notes.html">Redesign Notes</a></li><li><a href="/summary-of-various-exciting-css-drafts-and-proposals.html">Summary of various exciting CSS drafts and proposals</a></li><li><a href="/this-revolution-needs-new-revolutionaries.html">This revolution needs new revolutionaries</a></li><li><a href="/some-css-transition-hacks.html">Some CSS Transition hacks</a></li><li><a href="/safe-css-defaults.html">Safe CSS Defaults</a></li><li><a href="/unplugged-2011.html">Unplugged 2011</a></li><li><a href="/bokeh-with-css3-gradients.html">Bokeh with CSS3 Gradients</a></li><li><a href="/making-pure-css3-demos-better.html">Making "Pure CSS3" demos better</a></li><li><a href="/web-opener-at-opera.html">Web Opener at Opera</a></li><li><a class="btn" href="/categories/web-development/">More</a></li></ul>
<footer role="contentinfo"><p>
Copy to your heart’s content 2013 - Divya Manian -
<span class="credit">Powered by <a href="">Octopress</a></span>
<script type="text/javascript">
var disqus_shortname = 'nimbublog';
var disqus_developer = 1;
var disqus_url = '';
var disqus_identifier = '';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<script src="/javascripts/octopress.js"></script>
var _gaq=[['_setAccount','UA-97188-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
Jump to Line
Something went wrong with that request. Please try again.