Customization Issue


Hey, I'm working with a client and he wants me to add the count for the comments and the views per page, and also underneath the single image, be able to show a gallery album. I have completed the task for the views, that was easy, I just added my own PHP script and it works, but so far, I cannot have accurate comments count, I know Buddypress uses a different comments function as Wordpress does default, any advice on how I can add this and also show the the rest of his album as thumbnails under the image?


If anyone can reply, this need to be done asap.


@tenoch - You can use the WordPress comment count function to fetch the comment counts -> Also you would need rtmedia_media_id($rtmedia_id) function to get the actual WordPress attachment id.

For the user albums you could try this.

$user_id = bp_displayed_user_id();  
$model = new RTMediaModel();  

$results = $model->get(array('media_type' => 'album', 'media_author' => $user_id));  

You should get your result from the above query. Also the above query accepts arguments in the form of the rt_rtm_media database table columns.


I tried this but it's not displaying, I added it to the media templates file called media-single.php, am I perhaps putting the code in the wrong area? As said he wants it on a single view, but with more from the user's gallery under it, also the comments as said above, and just to make sure, as my code for views seems to work, is there a best way to count views on the page. My code seems to work, but it only saves it by session and I'm afraid it might lose the data if the session is exited.


@tenoch - If you used the above code as given you won't get an output. Perhaps you could do a var_dump or print_r of the above mentioned $results to get an idea of what you could use from it in your template.

Regarding view count, it has been implemented in the latest version of rtMedia. Only you would need to fetch it. You could use get_rtmedia_meta($rtmedia_id, 'view') to get the view count of a particular media item.


I'll try that in a bit, thanks very much though mate, you're a life safer.


I'm still a bit lost, assume here please that I am a total newb (not really a php developer, my role is more of a web designer), do you mind showing me the exact steps required, usually I'm okay with stuff like theme development for Wordpress, but I've never worked with specifically developing or adding to plugins. Also I assume I'm adding to the right file (media-single.php), as it does show up changes there.


@tenoch - Unfortunately that is a little out of scope for the help and support that we can provide to the community. Try doing echo get_rtmedia_meta($rtmedia_id, 'view') to get a hold of a particular media's veiw count where $rtmedia_id represents the rtmedia id of the media.

Regarding the query that i had given in the previous comment. You can follow it up with print_r($results) so as to list the results that can be then put in a foreach loop as per your requirement.


I understand that, I'm just worried about doing the comment count and the view count, because when I do the viewcount, it's only showing the wordpress comments as a whole. All I want to do is add it so that it globally displays the views and comments count for all rtMedia user images.


@tenoch - I din't get the part

because when I do the viewcount, it’s only showing the wordpress comments as a whole

The code for veiw count doesn't include the comment count. It just shows the number of views a particular media has got. Getting a little confused regarding what exactly is your issue here.


Let me explain :

I make it count the comments as per your example, what it does is NOT load the comments from rtMedia, but ALL wordpress comments in the blog/site.

As to the WP view count, I'm not sure exactly what you mean in how to implement it.


@tenoch - For getting a media's view count you could use the function echo get_rtmedia_meta($rtmedia_id, 'view'); where $rtmedia_id corresponds to the respected rtmedia_id of the media whose count you want to fetch.

For the comment listing you should try using rtmedia_comments().