Hello,
with template exemple : I want not to display "no comment". But I want also, if there are one or more comments, display title "One comment" or "2 comments", etc. as a title.
(for example, the source would be: `
One comment
, 2 comments
` etc.)
I take the code for comments in exemple template. It is:
`<?php $num = getCommentCount(); echo ($num == 0) ? gettext("No comments") : (($num == 1) ? gettext("<strong>One comment") : "$num ".gettext("comments on this album:")); ?>`
I try to put `...
` only when there are comments and disable "no comment" when there is no comment.
I Write:
`<?php $num = getCommentCount(); echo ($num == 0) ? "" : (($num == 1) ? echo "<h3>" gettext("One comment") : "$num ".gettext("comments on this album:")); ?>`
That don't work.
One idea?
Comments
<?php $num = getCommentCount();
if ($num != 0) {
if($num == 1) {
<display one comment>
} else {
}
}
`
Sometimes the long written version is more clear than the short term...:-)
`
<?php $num = getCommentCount();
if ($num != 0) {
if($num == 1) {
gettext("<strong>One comment")
} else {
"$num ".gettext("comments on this image:")
}
}
?>
`
but I have message error...
`
<?php $num = getCommentCount();
if ($num != 0) {
if($num == 1) {
echo gettext("<strong>One comment");
} else {
echo "$num ".gettext("comments on this image:");
}
}
?>
`
Please try to learn the basics of php. There are lots of tutorials out there. I hope you will understand that we can't teach those here.
To finish this post, I correct it and include `
...
` with "One comment" and "xx comments". There is nothing in the code source if there is 0 comments (no h3 balises empty).This code is ok:
`
<?php $num = getCommentCount();
if ($num != 0) {
if($num == 1) {
echo "<h3>".gettext("One comment")."";
} else {
echo "
$num ".gettext("comments on this image:")."
";}
}
?>
`
Thank you.