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.

What’s going on in WHM?

Discussion in 'cPanel Developers' started by cPanelAdamF, Apr 5, 2017.

  1. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    190
    Likes Received:
    16
    Trophy Points:
    93
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Reposting snippet here from a very important blog post which plugin developers should read:

    Hi Everyone, Adam here. I wanted to spend some time spelling out what’s going on in the user experience of cPanel & WHM. Plugin developers should pay close attention to the changes we’re making.

    Now that we’ve fully deprecated the X3 theme, it’s time to turn our attention to WHM. We’ve got some very simple goals when it comes to WHM:

    1. Ensure a great experience for our advanced users
    2. Assist first-time users who come to WHM with no previous system administration experience
    3. Prepare for the mobile age, where laptops and desktops aren’t the only way system administration is done
    Read What’s going on in WHM? | cPanel Blog for more information
     
  2. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    190
    Likes Received:
    16
    Trophy Points:
    93
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    For PHP plugin developers who need a temporary workaround while we make changes in WHM, here's a path you could take to bring the WHM interface chrome into your plugin.

    Again, this is only a temporary workaround. We'll be expanding plugin support in WHM as a part of the WHM work. Stay tuned for those updates.

    In testPlugin.html.tt

    Code:
    [%
    USE Whostmgr;
    USE JSON;
    
    IF locale.get_html_dir_attr() == 'rtl';
    SET rtl_bootstrap = Whostmgr.find_file_url('/3rdparty/bootstrap-rtl/optimized/dist/css/bootstrap-rtl.min.css');
    END;
    
    SET styleSheets = [
       rtl_bootstrap,
       '/libraries/fontawesome/css/font-awesome.min.css'
       ];
    
    WRAPPER 'master_templates/master.tmpl'
       header = locale.maketext("WHM Example Plugin")
       stylesheets = styleSheets,
       theme='bootstrap';
    %]
    
    <iframe  frameBorder="0" scrolling="no" width=100% height=100% src="./test.php"></iframe>
    
    [% END %]
    In this example, the iframe's SRC value should point to the index page of your plugin.

    NOTE: the above code snippet widget is scrollable. Remember to copy-pasta the whole thing.

    In /usr/local/cpanel/whostmgr/docroot/cgi/testPlugin/index.cgi
    Code:
    #!/usr/local/cpanel/3rdparty/bin/perl
     use strict;
     package cgi::examplePlugin;
     use warnings;
     use Cpanel::Template                  ();
    
     run() unless caller();
    
     sub run {
        print "HTTP/1.0 200\r\n OK Content-type: text/html; charset=\"utf-8\"\r\n\r\n";
        Cpanel::Template::process_template(
            'whostmgr',
            {
                'template_file' => 'testPlugin.html.tt',
                'print'         => 1,
            }
        );
        exit;
     }
     
    #2 cPanelAdamF, Apr 12, 2017
    Last edited: Apr 12, 2017
  3. fevangelou

    fevangelou Member

    Joined:
    Oct 10, 2010
    Messages:
    22
    Likes Received:
    3
    Trophy Points:
    53
    Location:
    Athens, Greece
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    A couple of clarifications/questions if you don't mind...

    a) Should the file testPlugin.html.tt be saved in the /usr/local/cpanel/whostmgr/docroot/templates/ directory?
    b) You refer to an iframe's src attribute yet I don't see any iframe tag in the code above. Did you mean that in order to have the header brought into a plugin we should create an iframe tag containing the .cgi file as src?

    Thank you.
     
  4. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    190
    Likes Received:
    16
    Trophy Points:
    93
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    testPlugin.html.tt should be saved in your plugin's directory inside /usr/local/cpanel/whostmgr/docroot/templates/. Additionally you can name it whatever you'd like (not just testPlugin.html.tt).

    You may have to scroll within the code snippet to see it.
     
  5. Harlequin

    Harlequin Active Member

    Joined:
    Sep 4, 2011
    Messages:
    39
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Santa Cruz de Tenerife, Spain
    cPanel Access Level:
    Reseller Owner
    Twitter:
    After years of X3 I kind of miss it but hey... Progress and all that.
     
  6. fevangelou

    fevangelou Member

    Joined:
    Oct 10, 2010
    Messages:
    22
    Likes Received:
    3
    Trophy Points:
    53
    Location:
    Athens, Greece
    cPanel Access Level:
    DataCenter Provider
    Twitter:
Loading...

Share This Page