Drupal: .htaccess Access Deny
August 21, 2012 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

First let’s speak about Order directive of .htaccess file of Apache server.
Description: …

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

How to Add a JomComment Comment Counter to Your Joomla-Powered Blog

Submitted by on October 7, 2009 – 5:09 am24 Comments

This article is about adding a comment counter to a Joomla-powered blog with JomComment. Besides having the usual "Add Comment (2)" link at the end of each article introduction, it allows to add a comment counter and link along with the "Written by…," date, section, and category.

With the ability to override Joomla’s core content output in a Joomla 1.5 template, you can do virtually anything within your template. This tutorial demonstrates how to use template overrides to insert a JomComment comment counter anywhere you want to add it in your articles.


1. Override the content component output in your template

This section will give you a brief overview of the process of how to override the content component’s output in your template. The Joomla 1.5 framework gives you the ability to override the HTML output of any core component and third-party components that are built to support this feature. The Beez template that comes pre-installed with Joomla 1.5 is a great example of what can be done with template overrides, and the best place to start if you are building a template from scratch is to copy the "html" folder from the beez template to your template. (Warning: doing this could dramatically change the appearance of your site, so please try this out on a test server before attempting it on a live site!)

Once you have copied the html folder from the Beez template folder to your template folder, the template overrides for the content component can be found at "yoursite.com/templates/yourtemplate/html/com_content". There are four files that you need to work with in order to add the JomComment comment: counter:

  • article/default.php
  • category/blog_item.php
  • frontpage/default_item.php
  • section/blog_item.php

2. Get the number of comments for the article

The following counter code comes from the JomComment component. Add this code anywhere in each of the four files listed above.

<?php

require_once ( JPATH_BASE .DS.’components’.DS.’com_jomcomment’.DS.’helper’.DS.’minimal.helper.php’ );

$jcCount = jcCountComment($this->item->id);

?>

This little bit of code does two things. First, it references one of JomComment’s helper php files that contains a function, jcCountComment, that counts the number of comments for the article whose ID is passed as a parameter to the jcCountComment function. The second line gets the number of comments for the article by passing the article’s ID as $this->item->id, and it stores that number in the variable $jcCount.

3. Display the number of comments and link the number to the comment form

Now that you have the number of comments for the article, you’re halfway there. You still need to link the number to the comment form for the article. Here is the example of the code used to link to the comment form:

<img src="templates/htj_960/images/icon-addcomment.gif" width="15" height="14" alt="Add Comment" title="Add Comment" style="vertical-align: middle;" />

<a href="<?php echo $this->item->readmore_link; ?>#comments" class="commentslink" title="Add Comment">(<?php echo $jcCount; ?>)</a>

The first line is an image tag that displays an icon from the Fam Fam Fam silk icons collection. The href for the link uses the php parameter $this->item->readmore_link to link to the article, and adds the anchor #comments to link directly to the comments form for the article. Then, I used the $jcCount variable in parentheses to display the comment count as the link to the form.

24 Comments »

  • wholesale says:

    that is very usefull information

  • Hello there, just became alert to your blog through Google,
    and found that it’s truly informative. I’m going to watch out for brussels. I will be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

  • ejaculation says:

    You’ve made some decent points there. I looked on the web to learn more about the issue and found most people will go along with your views on this site.

  • Its like you read my mind! You appear to know a lot approximately this, like you wrote the e
    book in it or something. I believe that you can do with a few percent
    to power the message home a little bit, but other than that, that is wonderful
    blog. An excellent read. I will definitely be back.

  • Hi my family member! I wish to say that this article is awesome, nice written and include approximately all significant infos.
    I would like to look extra posts like this
    .

  • I don’t even know how I ended up here, but I thought this post was good. I do not know who you are but definitely you are going to a famous blogger if you aren’t already ;) Cheers!

  • Everything is very open with a very clear description of the issues.

    It was definitely informative. Your website is extremely helpful.

    Thank you for sharing!

  • euro car says:

    I’m so very glad to see there is actually a little excellent content left on the internet. I’m fed up with google sending me garbage.

  • Wow, marvelous blog format! How lengthy have you been running a blog for?
    you made blogging glance easy. The total
    look of your site is excellent, let alone the content material!

  • lionel messi says:

    Hello there, I do believe your web site may be having internet browser compatibility issues.
    Whenever I look at your site in Safari, it looks fine
    but when opening in Internet Explorer, it’s got some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, wonderful blog!

  • Do you mind if I quote a couple of your posts as long as I provide
    credit and sources back to your website? My blog site is in the exact same niche as yours and my visitors would genuinely benefit from a lot of the information
    you provide here. Please let me know if this ok with you.
    Cheers!

  • cool says:

    Currently it looks like Expression Engine is the best blogging
    platform out there right now. (from what I’ve read) Is that what you are using on your blog?

  • Good day! This post could not be written any better! Reading this
    post reminds me of my previous room mate! He always kept talking about this.
    I will forward this article to him. Pretty sure he will have a good read.
    Thanks for sharing!

  • This blog really keeps getting more impressive every time I show up.
    You should absolutely be satisfied.

  • Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog
    that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

  • I am really glad I have found this information.
    Today bloggers publish just about gossips and net and this is really
    frustrating. A good website with interesting content, this is what I need.

    Thank you for keeping this website, I will be visiting it.
    Do you do newsletters? Cant find it.

  • tan sofas says:

    Good day! This is kind of off topic but I need some help from an established blog.
    Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about creating my own but I’m not sure where to start. Do you have any points or suggestions? Cheers

  • Hello would you mind letting me know which webhost you’re using? I’ve loaded your blog in 3 completely different web browsers and I must say this blog loads a lot faster then most. Can you suggest a good internet hosting provider at a fair price? Kudos, I appreciate it!

  • I was able to find good advice from your content.

  • Hey there, You’ve done a fantastic job. I will definitely digg it and personally recommend to my friends. I’m confident they’ll be benefited from this website.

  • Your means of describing all in this post is actually pleasant,
    every one can without difficulty understand it, Thanks a lot.

  • Here says:

    Prеtty! Τhis haѕ beеn a rеally ωonderful aгtiсle.
    Thank уou for prοѵiding thіs info.

  • une femme says:

    Hmm it looks like your site ate my first comment (it was
    extremely long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to everything. Do you have any tips for first-time blog writers? I’d really appreciate it.

  • military says:

    Nice answer back in return of this query with
    solid arguments and explaining everything about
    that.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.