Howdy all,
I'm just getting started with b2evo and I've come across something that I think could be updated. The comments_number() function defaults to using three different texts to describe there are are any comments. I want to display one message like this: "Display Comments / Leave a Comment (#)" regardless of how many comments are to be displayed. Am I the only one that wants to use this function this way or is there another function I should be using?
Below is the updated function code for anyone who's interested in it:
//////
// UPDATED: 03.10.08 - Changed comments_number() function to use one
// message by default. Additional message for 1 comment or multiple
// comments can still be used by including their text in the function
// call or by using "#" to use the default text.
function comments_number( $zero='#', $one='', $more='' )
{
if( $zero == '#' ) $zero = T_('Leave a comment');
if( $one == '#' ) $one = T_('1 comment');
if( $more == '#' ) $more = T_('% comments');
//////
// Check to see if all messages should default to $zero text
if( $one == '' ) $one = $zero;
if( $more == '' ) $more = $zero;
// original hack by dodo@regretless.com
global $id,$postdata,$tablecomments,$c,$querycount,$cache_commentsnumber,$use_cache;
$number = generic_ctp_number($id, 'comments');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
//////
// REMOVED: 03.10.08 - Code rendered redundent by below code
// $n = $number;
// $more=str_replace('%', $n, $more);
$blah = $more;
}
echo str_replace( '%', $number, $blah );
}
Travis
Just pass the same string 3 times! :P