How To Show User A Random Video In ClipBucket

It is good to have a button on website which users can click to watch a random video. It comes in handy when users are bored and don’t know what to watch. With help of this button you can decrease bounce rate and make user stay for longer on website.

Step 1:

Go to your main directory where Clipbucket is installed (public_html in most cases) and create a new file named randomvid.php. You can name it anything you want but this is what we will be using for this tutorial.

Step 2:

Now paste the below code in your newly created file.

| Copyright (c) 2007-2009 All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , ©
require 'includes/';
$urls = array (
'Your page URL',
'Your page URL',
'Your page URL',
'Your page URL',
$random = rand(1, count($urls));
$link = $urls[$random];
Header("Location:" . $link);
//Displaying The Template

What is this code doing?

This variable stores list of URLs out of which some URL you’d like your users to see upon clicking button.

rand() is a PHP function that shows random things from an array. It takes $url array and counts all urls and then picks one of them.

This variable stores the currently picked URL

Currently picked URL in $link variable is shown.

Step 3:

Navigate to Styles / yourtheme / layout and create a new file called randomvid.html
Leave this file empty and hit save button.

Step 4:

Now open header.html and add below code where you want the link to appear.

Note: Add the same code anywhere on your website and this feature will work just fine.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 1.00 out of 5)