Recent Topics

1 Sep 15, 2004 17:47    

How would I change the way comments are displayed in a skin/template?

If Closed -> Show 'Comments Closed'
If Disabled -> don't show anything
If Open -> Show the number of Comments -> Comments (10)

I know it has something to do with:
php $Item->feedback_link() // Link to comments

I just need a little more info.

2 Sep 15, 2004 21:33

Here's a little info: http://doc.b2evolution.net/0.9.0/evocore/Item.html#feedback_link

Here's some more info:http://doc.b2evolution.net/0.9.0/evocore/Item.html#feedback_link wrote:

feedback_link()

Template function: Displays link to feedback page (under some conditions)
void feedback_link( [ string $type = 'feedbacks' ] , [ string $before = '' ] , [ string $after = '' ] , [ string $zero = '#' ] , [ string $one = '#' ] , [ string $more = '#' ] , [ string $title = '#' ] , [ boolean $use_popup = '#' ] , [ boolean $hideifnone = '#' ] , [ string $mode = '' ] , [ string $blogurl = '' ] )
Parameters:
string $type: Type of feedback to link to (feedbacks (all)/comments/trackbacks/pingbacks)
string $before: String to display before the link (if comments are to be displayed)
string $after: String to display after the link (if comments are to be displayed)
string $zero: Link text to display when there are 0 comments
string $one: Link text to display when there is 1 comment
string $more: Link text to display when there are >1 comments (include %d for # of comments)
string $title: Link title
boolean $use_popup: true to use a popup windows ('#' to use if comments_popup_windows() is there)
boolean $hideifnone: true to hide if no feedback ('#' for default)
string $mode: 'pid' or 'title'
string $blogurl: url to use

Here's all the info:

	/*
	 * Template function: Displays link to feedback page (under some conditions)
	 *
	 * {@internal Item::feedback_link(-)}}
	 *
	 * @param string Type of feedback to link to (feedbacks (all)/comments/trackbacks/pingbacks)
	 * @param string String to display before the link (if comments are to be displayed)
	 * @param string String to display after the link (if comments are to be displayed)
	 * @param boolean true to use a popup windows ('#' to use if comments_popup_windows() is there)
	 * @param boolean true to hide if no feedback ('#' for default)
	 * @param string Link text to display when there are 0 comments
	 * @param string Link text to display when there is 1 comment
	 * @param string Link text to display when there are >1 comments
	 * @param string Link title
	 * @param string 'pid' or 'title'
	 * @param string url to use
	 */
	function feedback_link( $type = 'feedbacks', $before = '', $after = '',
													$zero='#', $one='#', $more='#', $title='#',
													$use_popup = '#',
													$hideifnone = '#', $mode = '', $blogurl='' )
	{
		global $b2commentsjavascript, $BlogCache;

		switch( $type )
		{
			case 'feedbacks':
				if( $hideifnone == '#' ) $hideifnone = false;
				if( $title == '#' ) $title = T_('Display feedback / Leave a comment');
				if( $zero == '#' ) $zero = T_('Send feedback');
				if( $one == '#' ) $one = T_('1 feedback');
				if( $more == '#' ) $more = T_('%d feedbacks');
				break;

			case 'comments':
				if( ! $this->can_see_comments() )
					return false;
				if( $hideifnone == '#' )
				{
					if( $this->can_comment( '', '', '', '' ) )
						$hideifnone = false;
					else
						$hideifnone = true;
				}
				if( $title == '#' ) $title = T_('Display comments / Leave a comment');
				if( $zero == '#' ) $zero = T_('Leave a comment');
				if( $one == '#' ) $one = T_('1 comment');
				if( $more == '#' ) $more = T_('%d comments');
				break;

			case 'trackbacks':
				$current_Blog = $BlogCache->get_by_ID( $this->blog_ID );
				if( ! $current_Blog->get( 'allowtrackbacks' ) )
				{	// Trackbacks not allowed on this blog:
					return;
				}
				if( $hideifnone == '#' ) $hideifnone = false;
				if( $title == '#' ) $title = T_('Display trackbacks / Get trackback address for this post');
				if( $zero == '#' ) $zero = T_('Trackback (0)');
				if( $one == '#' ) $one = T_('Trackback (1)');
				if( $more == '#' ) $more = T_('Trackbacks (%d)');
				break;

			case 'pingbacks':
				$current_Blog = $BlogCache->get_by_ID( $this->blog_ID );
				if( ! $current_Blog->get( 'allowpingbacks' ) )
				{	// Pingbacks not allowed on this blog:
					return;
				}
				if( $hideifnone == '#' ) $hideifnone = true;
				if( $title == '#' ) $title = T_('Display pingbacks');
				if( $zero == '#' ) $zero = T_('Pingback (0)');
				if( $one == '#' ) $one = T_('Pingback (1)');
				if( $more == '#' ) $more = T_('Pingbacks (%d)');
				break;

			default:
				die( "Unkown feedback type [$type]" );
		}

		if( $use_popup == '#' )
		{	// Use popups if javascript is included in page
			$use_popup = $b2commentsjavascript;
		}

		$number = generic_ctp_number($this->ID, $type);

		if( ($number == 0) && $hideifnone )
			return false;

		$url = $this->gen_permalink( $mode, $blogurl, true );
		if( $use_popup )
		{ // We need to tell b2evo to use the popup template
			$url = url_add_param( $url, 'template=popup' );
		}

		echo $before;

		echo '<a href="', $url;
		echo '#', $type, '" ';	// Position on feedback
		echo 'title="', $title, '"';
		if( $use_popup ) echo '" onclick="b2open(this.href); return false"';
		echo '>';

		if( $number == 0 )
			echo $zero;
		elseif( $number == 1 )
			echo $one;
		elseif( $number > 1 )
			echo str_replace( '%d', $number, $more );

		echo '</a>';

		echo $after;

	}

3 Sep 15, 2004 22:57

Ok, I tried:
$Item->feedback_link( 'comments','','','#','#','#','#','#','0' );

But when comments are set to closed it displays "Leave a Comment", I would like it to say "Comments are closed"

I guess I don't quite understand.


Form is loading...