Add TubePress to any PHP Page

It's very easy to integrate TubePress into any PHP page on your website. For demonstration purposes, we will use the very simple PHP/HTML file show below. Feel free to create this file to test, or extrapolate the concepts into your existing PHP pages.
This article is part of a series on getting started using TubePress in standalone PHP.
Warning

Please ensure that you have completed your initial setup before going further.

It's very easy to integrate TubePress into any PHP page on your website. For demonstration purposes, we will use the very simple PHP/HTML file show below. Feel free to create this file to test, or extrapolate the concepts into your existing PHP pages.

<?php

if (!defined('TUBEPRESS_CONTENT_DIRECTORY')) {
  define('TUBEPRESS_CONTENT_DIRECTORY', '/some/directory/tubepress-content');
}

include "/var/www/html/myblog.com/lib/tubepress_pro_x_y_z/src/TubePressPro.php";
    
?>

<html>
  <head>
    <title>TubePress Pro</title>
        
    <?php print TubePressPro::getCSS(); ?>
  </head>
    
  <body>
        
    <?php print TubePressPro::getHTML('mode="tag" tagValue="pittsburgh steelers" resultsPerPage="3"'); ?>
        
    <?php print TubePressPro::getJS(true); ?>
        
  </body>
</html>

Let’s study this file in detail.

  1.  
    if (!defined('TUBEPRESS_CONTENT_DIRECTORY')) {
      define('TUBEPRESS_CONTENT_DIRECTORY', '/some/directory/tubepress-content');
    }
    

    Set the constant TUBEPRESS_CONTENT_DIRECTORY to the absolute filesystem path to your tubepress-content directory which you uploaded during installation.



  2.  
    include "/var/www/html/myblog.com/lib/tubepress_pro_x_y_z/src/TubePressPro.php";

    Include the file TubePressPro.php. This will always be located in your TubePress installation at tubepress_pro_x_y_z/src/TubePressPro.php.



  3.  
    <?php print TubePressPro::getCSS(); ?>

    Call TubePressPro::getCSS() in the HTML head of your document to print out TubePress’s CSS stylesheet tags and inline CSS.



  4.  
    <?php print TubePressPro::getHTML('mode="tag" tagValue="pittsburgh steelers" resultsPerPage="3"'); ?>

    Call TubePressPro::getHTML() anywhere you’d like to insert TubePress. This function takes a string which consists of space-separated name/value pairs of TubePress options. You may repeat this function call as many times as you like throughout the page.



  5.  
    <?php print TubePressPro::getJS(true); ?>

    Call TubePressPro::getJS() near the closing </body> tag to print out TubePress’s JavaScript tags and inline JavaScript. It takes a single parameter which indicates whether or not to include jQuery. If you are already including jQuery elsewhere in your document, use false for this parameter.



Last Updated Oct 08, 2015 05:57PM PDT
c65861bf7a72e1a8878bdf73cabbbdbf@tubepress.desk-mail.com
http://assets3.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete