The Joomla! Forum ™



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 new topic Reply to topic  [ 2 posts ] 

Get Itemid of content in template (index.php)
1 0%  0%  [ 0 ]
2 100%  100%  [ 1 ]
Total votes : 1
Author Message
PostPosted: Wed Dec 12, 2007 9:50 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 22, 2007 1:35 pm
Posts: 10
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...


Top
 Profile  
 
PostPosted: Thu Dec 13, 2007 8:59 pm 
Joomla! Enthusiast
Joomla! Enthusiast

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

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:
param name="show_comments" type="list" default="1" label="Show Comments" description="Show Comments?">
         <option value="0">No</option>
         <option value="1">Yes</option>
</param>


You may want to have a spacer right after this parameter:

Code:
<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:
/components/com_yvcomment/views/comment/tmpl/default/deafult.php

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:
$articleparams = new JParameter($yvComment->_article->attribs


Now let's get your custom parameter into an if....else statement:

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

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



That's about it!

Best of luck!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 



Who is online

Users browsing this forum: No registered users and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group