[ Video Sharing CMS v4 ] Preview Video and Next Video Button

Started by megaman79,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

megaman79Topic starter

Hello PHPVibe,

What's the code to call the Previous Video and the Next Video.

I want to add two Bottom in the Video section, so when user click Next Video Buttom => Go to the Next Video or Go Back to Previous Video.

Thansk for the support,
"Very Happy with PHPVibe"
  •  

TheBritain

I don't know if a function already exist, but here's how I would do it:

If you look in vibe_videos, you will notice that there is an ID.
If you open ./tpl/main/video.php, this is the script for the video page.
If you want to access the video id, that would be:

video->id


Example, this will print out the video id:

<?php echo _html($video->id);?>


So, the way I would do it, and this may or may not be correct. Would be to get the current id, add one, and do a query to see if it exist. If it does, then go to that video. You are probably wondering how to get the link. If you look at video-loop.php, it has the answer to that as well. After you determined that the required entry exist, assign the link to the 'next button' using this bit of code:

video_url($video->id , $video->title)


That returns the URL of the video, replace $video->id, with the current ID plus 1.

The back button is similar with an extra check. The IDs start with 1 in the database. So if the ID = 1, then don't assign the back button.

Remember to always do a query to see if the desired video exist.

Sometimes, videos will be deleted from the database, somehow, just assume it can happen. That, or they may become private, unlisted, ect. So when checking the forward or backward query. Make sure to ALSO check the related properties.

If they fail a check, keep looping backwards or forwards until you reach 1 or the max count respectively. This will always ensure you get to the next available video. I hope this helps.
  •  

Marius P.

guess_next() function in lib/functions.php will give you the next's details.
previous remains in session (see this upcoming upgrade, or 3.5)
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (7)