Jump to content


These Forums Are Now Read-Only


For TubePress support, please post a question here or open a support ticket and we will be glad to assist.


Photo

Randomized single video?


  • Please log in to reply
4 replies to this topic

#1 Paul Franz

Paul Franz

    Member

  • Members
  • PipPip
  • 14 posts

Posted 08 September 2010 - 04:15 PM

Tell me if this is possible:

I have a colleague whose Web site at travisfox.com uses TubePress. The thing is, his homepage has a single embedded player that randomizes the video that's played from Travis' Vimeo channel. So if I go to the site, one video will be loaded up, and if I refresh the page, a different video will be selected.

Is this something that TubePress could do natively? Or would I have to use some JQuery to get it to work that way?

#2 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 08 September 2010 - 04:44 PM

This is possible with TubePress. There are a number of ways I would do it...

  • Create a custom HTML template that doesn't show any thumbnails and displays a gallery with orderBy="random". This would have the same effect that you're seeing on Travis's site. You'd basically just need to edit tubepress_pro_2_0_0/ui/gallery/html_templates/default.tpl.php and delete lines 28-130. Here's more info on how to use custom templates with TubePress: http://tubepress.com...#html_templates
  • Do the same thing, but instead of using a custom template to hide the thumbnails just hide them with jQuery and/or CSS. Just set display: none for div.tubepress_thumbnail_area. This is a little less efficient, but might be easier for you if you don't feel like using a custom template
  • Use a little PHP to pick from a list of videos and display one with TubePress. I personally like this one the best because you can get all the video's meta information (http://tubepress.com..._a_single_video). Here's some pseudocode...

    $videoIds = array('videoid1', 'videoid2', ...);$videoIdToDisplay = $videoIds[array_rand($videoIds)];print tubepressGallery("video='$videoIdToDisplay'");
Hope this answers your question. Let me know how else I can help!

#3 Paul Franz

Paul Franz

    Member

  • Members
  • PipPip
  • 14 posts

Posted 09 September 2010 - 01:55 PM

Almost -- in my situation, I don't think the first option would work.

Tell me the best solution in this case:

If you check out www.paul-franz.com, my homepage isn't programmed within the WP loop. All I've done right now is put a Vimeo embed code into the home.php file, plus a get_header and get_footer. That's it. It's not a post and it's not a page. So I can't use the WP GUI to use the [tubepress] shortcode?

I'm a bit of a newbie when it comes to figuring out PHP. I know my way around, but some of this stuff I just can't understand.

#4 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 09 September 2010 - 06:46 PM

OK, this should be pretty simple. TubePress Pro works happily inside a WordPress template. We'll be following the instructions from here: http://tubepress.com...plates_pro_only.

In your case, your home.php file is even simpler. I'm guessing it looks something like this:

<?php      get_header();   //your existing Vimeo embed HTML      get_footer(); ?>

Adding TubePress Pro abilities to this template consists of the 2 steps found at http://tubepress.com...plates_pro_only. Following those instructions alone, your home.php should look like this:

<?php      get_header();    include "/var/www/html/wp-content/plugins/tubepress_pro_2_0_0/env/pro/tubepress-pro.php";    print tubepressGallery('mode="tag" tagValue="barack obama" resultsPerPage="3"');    get_footer(); ?>

Now, let's modify it once more. This time we'll tell TubePress to pick a video randomly from a list of video IDs and display one of them.

<?php      get_header();    include "/var/www/html/wp-content/plugins/tubepress_pro_2_0_0/env/pro/tubepress-pro.php";    $videoIds = array('videoid1', 'videoid2', ...);    $videoIdToDisplay = $videoIds[array_rand($videoIds)];    print tubepressGallery("video='$videoIdToDisplay'");    get_footer(); ?>

Of course, you'll want to fill in your actual video IDs that you want to display. And replace "/var/www/html" with the actual path to your files on your web server. Please be careful of using single quotes vs. double quotes - PHP can be picky about that. All this should do the trick. Let me know how else I can help. Thanks.

#5 Paul Franz

Paul Franz

    Member

  • Members
  • PipPip
  • 14 posts

Posted 12 September 2010 - 01:45 PM

Eric, it works perfectly. You are a PHP god. Well worth the $25 subscription.

Check it out:

www.paul-franz.com