Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

set variables based off of an api

Discussion in 'cPanel Developers' started by morissette, May 1, 2012.

  1. morissette

    morissette Well-Known Member

    Joined:
    May 24, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    66
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    Hey all,

    I don't suppose it's possible to set variables based off of an api call something that would be like

    my($pref, $exchange) = return of <?cp Email::listmxs(% %, entries:: ${priority}:, entries:: ${mx}:) domain=$FORM{'domain'} ?>

    Any idea on this?

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,480
    Likes Received:
    29
    Trophy Points:
    158
    cPanel Access Level:
    DataCenter Provider
    It would probably best to use the template toolkit interface with <?cptt mail/yourfile.tmpl ?>

    Then yourfile.tmpl
    Code:
    [%
    USE Api2;
    USE CPList;
    USE HTTP;
    USE JSON;
    USE NVData;
    
    SET result =  Api2.exec( 'Email', 'listmxs', { domain =>CPANEL.FORM.domain } );
    
    %]
    
    For a better example see
    /usr/local/cpanel/base/frontend/x3/stats/lastvisit.html
    and
    /usr/local/cpanel/base/frontend/x3/stats/latest_visitors_entries.tmpl


    Also http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/UsingCpttTags


    **Note cptt is a bit slow in 11.32. cptt has been improved significantly in 11.34, however the speed improvements are not yet available publicly.
     
  3. morissette

    morissette Well-Known Member

    Joined:
    May 24, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    66
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    Thanks! That helps significantly.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice