Hi there. I’m trying to modify media-gallery.php to add counts for views, likes and comments. I was able to create a like counter by adding this:
<?php
$mediamodel = new RTMediaModel();
$likecount = $mediamodel->get( array( 'id' => rtmedia_id() ) );
if ( isset( $likecount[ 0 ]->likes ) ){
$likecount = intval($likecount[ 0 ]->likes);
} else {
$likecount = 0;
}
?>
<i class="rtmicon-thumbs-up rtmicon-fw"></i> <?php echo $likecount; ?>
And tried to create comments or views counter the same way:
<?php
$mediamodel = new RTMediaModel();
$commentcount = $mediamodel->get( array( 'id' => rtmedia_id() ) );
if ( isset( $commentcount[ 0 ]->comments ) ){
$commentcount = intval($commentcount[ 0 ]->comments);
} else {
$commentcount = 0;
}
?>
<i class="rtmicon-comment rtmicon-fw"></i> <?php echo $commentcount; ?>
<?php
$mediamodel = new RTMediaModel();
$viewscount = $mediamodel->get( array( 'id' => rtmedia_id() ) );
if ( isset( $viewscount[ 0 ]->views ) ){
$viewscount = intval($viewscount[ 0 ]->views);
} else {
$viewscount = 0;
}
?>
<i class="rtmicon-eye rtmicon-fw"></i> <?php echo $viewscount; ?>
But it doesn’t seem to do the trick. And i really ■■■■ at PHP. Can anyone please help me on this one?