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.

Branding livePHP

Discussion in 'cPanel Developers' started by SE_Frank, Oct 21, 2010.

  1. SE_Frank

    SE_Frank Member

    Joined:
    Oct 21, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    In reference to ticket 929450.

    ===

    I'd like to request a feature. We're working on a cPanel / WHM addon but in order to get our script (which *requires* to end with .live.php) branded we're using jQuery to dynamically load the contents from index.html.

    In this index.html, the tags:
    PHP:
    <cpanel Branding="include(stdheader.html)">
    and

    PHP:
    <cpanel Branding="include(stdfooter.html)">
    have been used. This sort-of works, but requires the user to have Javascript enabled. Also, this workaround is prone to errors.

    If there was a way to include the header & footer in a .live.php file, this makes integrating addons in cPanel a lot easier.
     
    #1 SE_Frank, Oct 21, 2010
    Last edited: Oct 21, 2010
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Frank,
    We recently overhauled how LivePHP works that will allow pages like this to be loaded via LivePHP functions. This has been included in versions of cPanel & WHM with a version greater than 11.28.56 (meaning it is in RELEASE now).

    To template your page via LivePHP you can do something like the following::

    PHP:
    <?php
    include("/usr/local/cpanel/php/cpanel.php");

    $cpanel = &new CPANEL();
    $header $cpanel->api1('Branding','include',array('stdheader.html'));
    print 
    $header['cpanelresult']['data']['result'];
    ?>
    <div class="body-content">

    __PUT_YOUR_CODE_HERE__

    </div>
    <?php
    $footer 
    $cpanel->api1('Branding','include',array('stdfooter.html'));
    print 
    $footer['cpanelresult']['data']['result'];
    $cpanel->end();

    ?>
     
  3. mrhillsman

    mrhillsman Registered

    Joined:
    Mar 21, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I like the LivePHP implementation, I just hope for more documentation for developers starting out with cPanel :)

    So here is my question, how does one, using LivePHP, implement this:

    <cpanel Branding="include(stdheader.html)">
    <cpanel setvar="headerimg=../images/topcgi.gif">
    <cpanel setvar="dprefix=../">

    Specifically, the setting of the dprefix variable so that my home button automatically goes back to the cPanel home page rather than back to the index page of the Plugin...thank you for your prompt response.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I'm moving this thread over to the integrations forum where you may get assistance from folks more familiar with this subject.
     
  5. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi mrhillsman,

    The following is a quick example of how to use the 'setvar' directive. The example lacks refinement but will give you an idea of the required syntax of the API request. So, adjust the values of those vars as necessary, any error checking on the Branding call, etc.

    'setvar' is interpreted by the cPanel API engine as an API1 module (with only one, implicit, function).

    PHP:
    <?php

    include("/usr/local/cpanel/php/cpanel.php");


    $cpanel = new CPANEL();
    $cpanel->api1("setvar","",array("dprefix=../"));
    $cpanel->api1("setvar","",array("headerimg=../images/topcgi.gif"));

    $r $cpanel->api1("Branding""include", array("stdheader.html"));
    echo 
    $r['cpanelresult']['data']['result'];
    print 
    "test complete\n";
    $cpanel->end();

    ?>
    Regards,
    -DavidN
     

Share This Page