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.

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:
    16
    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!
     
  2. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,426
    Likes Received:
    2
    Trophy Points:
    38
    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:
    16
    Location:
    Austin, TX
    cPanel Access Level:
    Root Administrator
    Thanks! That helps significantly.
     
Loading...

Share This Page