Get Itemid of content in template (index.php)

This forum is for general questions about extensions for Joomla! version 1.5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Post Reply

Get Itemid of content in template (index.php)

No votes
Total votes: 1

Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed Aug 22, 2007 1:35 pm

Get Itemid of content in template (index.php)

Post by vicky » Wed Dec 12, 2007 9:50 am

I am using yvcomments component to add comments in my site .

For some contents i dont want to give this option to add comments.

what i do to restrict this component not to show comments box.

thanks in advance...

Joomla! Enthusiast
Joomla! Enthusiast
Posts: 153
Joined: Fri Sep 21, 2007 3:44 pm

Re: Get Itemid of content in template (index.php)

Post by debreczeniandras » Thu Dec 13, 2007 8:59 pm


I needed to do the exact same thing.

1. First of all you may already know that the display of yvcomments may be ommited for certain section(s).
These can be set-up in the the Plugin Manager --> yvcomment --> List of Sections IDs which may, or may not, contain comments.

2. It was not enough for me either, so I set up a new parameter for my articles in the following file: /administrator/components/com_content/models/article.xml

Let's add a custom parameter into the advanced group as follows:

Code: Select all

param name="show_comments" type="list" default="1" label="Show Comments" description="Show Comments?">
			<option value="0">No</option>
			<option value="1">Yes</option>
You may want to have a spacer right after this parameter:

Code: Select all

<param name="@spacer" type="spacer" default="" label="" description="" />
Note the /> at the end of this parameter!!!

Your articles will be saved with this custom parameter. You only need to change it if you don't want to display the comments for an article, since your default value = 1.

3. Now let's set up yvcomment to know about our custom parameter:

This will be done in the following file:

The global $yvComment; object at the beginning of the file holds all information needed for this component (including your article and its parameters)

Let's create a JParameter object from the article parameters:

Code: Select all

$articleparams = new JParameter($yvComment->_article->attribs
Now let's get your custom parameter into an if....else statement:

Code: Select all

<?php if ($articleparams->get( 'show_comment' ) : ?>

<div class="yvComment"> 
<?php endif; ?>

That's about it!

Best of luck!

Post Reply

Return to “Extensions for Joomla! 1.5”