The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP LiveAPI Header

Discussion in 'User Experience' started by Krydos, Aug 26, 2016.

Tags:
  1. Krydos

    Krydos Member

    Joined:
    Jun 2, 2012
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
  2. Krydos

    Krydos Member

    Joined:
    Jun 2, 2012
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Here is how I do the header in x3:
    Code:
    require_once "/usr/local/cpanel/php/cpanel.php";
    $cpanel = new CPANEL();
    
    $res = $cpanel->api1("Branding", "include", array("stdheader.html"));
    print $res["cpanelresult"]["data"]["result"];
    
    I've tried that with paper_lantern and it sort of works, but some images are missing and it doesn't look quite right. Any ideas?
     
  3. Krydos

    Krydos Member

    Joined:
    Jun 2, 2012
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Since no one wanted to help me on this one I found a way to do what I was trying to do on my own. This is probably a pretty ugly hack, but it works.

    First I copied and split paper_lantern/branding/master.tt into two new files paper_lantern/branding/header.tt and paper_lantern/branding/footer.tt The header.tt file has everything from master.tt up until the tag.
    Code:
    [%- content -%]
    
    This tag indicates where the content of the page should be inserted into the paper_lantern themed page. Then the footer.tt file gets the contents of master.tt after that content tag.

    So then I created my new plugin index page such as paper_lantern/myplugin/index.phpcp It's important to use the phpcp extension at this point because when I tried this with .live.php extension it didn't work. Now to include the new header.tt file at the top and the footer.tt file at the bottom use this code.

    Code:
    <cpanel Branding="include(header.tt)">
    
    <?php
    echo "Hello world!";
    ?>
    
    <cpanel Branding="include(footer.tt)">
    
    This is the only way I've been able to create a properly branded paper_lantern themed page in cpanel 11.44. Feel free to post to this thread if you know of another way.

    EDIT:

    You will also need to edit the header.tt file and change this line from
    Code:
    SET directory_prefix = CPANEL.CPVAR.dprefix;
    
    to
    Code:
    SET directory_prefix = '../';
    
    in order for the header and footer links to work properly.
     
    #3 Krydos, Aug 28, 2016
    Last edited: Aug 28, 2016
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,474
    Likes Received:
    202
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    If that's not a typo, your cPanel is very much out of date.
     
  5. Krydos

    Krydos Member

    Joined:
    Jun 2, 2012
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    11.44 is the last version you can update to with the old /usr/ size recommendations. To upgrade beyond this version requires three times as much free space on /usr/ as previous cpanel versions. All of our newer servers which have a lot more free space on /usr/ because of the newer partition size recommendations are running the latest version of cpanel, but a couple older servers are unable to upgrade any further. Our plan is to get all of the user accounts moved off the old servers and then repartition the hard drives then they will be able to run the latest cpanel versions too.
     

Share This Page