TubePress provides an end-to-end, fully customizable solution for allowing your users to interactively search YouTube or Vimeo, all without leaving your website. The image below is a simple example showing an interactive search input along with a few results.
Like everything else with TubePress, interactive searching has loads of options and is fully customizable to suit your needs. To use the feature, you’ll need two invocations of TubePress on the page:
Let’s go over each invocation in detail.
Displaying a search input box and button is very easy with TubePress:
By default, the search form will submit back to the same page and TubePress will handle the submission. If you want the results to show up on another page, just set
searchResultsUrl. Please note that most users shouldn’t need to do this.
print TubePressPro::getHTML('output="searchInput" searchResultsUrl="http://mysite.com/videos.php"');
Now that you have a search input form, you’ll need to invoke TubePress somewhere else to display the search results.
Displaying search results is also easy. Add the following code wherever on the page you’d like the search results to show up:
print TubePressPro::getHTML('output="searchResults" searchProvider="vimeo"');
The searchProvider option can be set to either youtube or vimeo, and this determines if the gallery will display YouTube videos or Vimeo videos. TubePress will also display a placeholder gallery if the user isn’t searching (e.g. on their first visit to the page), but you can make it invisible until it has search results by setting
print TubePressPro::getHTML('output="searchResults" searchProvider="youtube" searchResultsOnly="true"');
With TubePress Pro, you can display search results asynchronously (i.e. without a full page load). It’s also a bit easier to set up than standard searching because you only need to invoke TubePress once on the page. The only catch is you also have to identify the DOM element where you want the search results to show up:
print TubePressPro::getHTML('output="ajaxSearchInput" searchResultsDomId="#somediv" searchProvider="vimeo"');
For the searchResultsDomId option value, just use any jQuery selector that uniquely identifies an existing DOM element on the page that can accept HTML.
By default, TubePress will search all of YouTube or Vimeo for the user's search
terms. If you'd like to narrow the results down to videos uploaded by a particular YouTube Channel/User
or Vimeo user, you can utilize the
For instance, to restrict search results to YouTube videos uploaded by
the YouTube channel
comedycentral, you might use the following shortcode:
print TubePressPro::getHTML('output="searchResults" searchProvider="youtube" searchResultsOnly="true" searchResultsRestrictedToUser="comedycentral"');