Page 1 of 1

Get Itemid of content in template (index.php)

Posted: Wed Dec 12, 2007 9:50 am
by vicky
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...

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

Posted: Thu Dec 13, 2007 8:59 pm
by debreczeniandras

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!