set variables based off of an api

morissette

Well-Known Member
May 24, 2009
119
2
66
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!
 

cPanelNick

Administrator
Staff member
Mar 9, 2015
3,483
35
208
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.