Getting Logged in users details (UID)
Hi,
I'm currently converting an x3 theme over to the Paper Lantern theme, the current x3 theme uses PHP and session variables to store some user information (uid, email), this is retrieved from doing api calls to '"127.0.0.1:2087/json-api/nvget?key=".$current_user_uid.":useremail"', then stores the results in a PHP session that the x3 theme can easily use when the php renders the front end. This plugin was originally created by a 3rd party company, so I'm now having to learn CPanel and understand the 3rd parties code.
Because we have to use the new Template Toolkit with Paper Lantern, I have no way of getting the PHP session variables across to the template file for the UI.
So from looking at the other template (*.tt) files it would seem I have to do the following call in my template file:
[% data = execute( 'NVdata', 'get', { names => 'megan'} ); %]
Where 'megan' is the current logged in username, and I hope from that I can get the (uid, email)
But I'm getting the following error:
Can anyone possibly give me any clues on what could be causing this and if I'm going about this the correct way?
Can't locate Cpanel/API/NVdata.pm in @INC (@INC contains: /usr/local/cpanel/Cpanel/CPAN/overload/__Digest /usr/local/cpanel/Cpanel/CPAN/overload/__Time /usr/local/cpanel /usr/local/cpanel /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/5.14.4/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/5.14.4 /usr/local/cpanel /opt/cpanel/perl5/514/site_lib/x86_64-linux-64int /opt/cpanel/perl5/514/site_lib) at (eval 19) line 1.
at (eval 19) line 1.
Cpanel::LoadModule::BEGIN() called at (eval 19) line 1
eval {...} called at (eval 19) line 1
eval ' use Cpanel::API::NVdata; Cpanel::API::NVdata::API::NVdata_init() if "Cpanel::API::NVdata"->can("API::NVdata_init");
;' called at /usr/local/cpanel/Cpanel/LoadModule.pm line 135
Cpanel::LoadModule::_modloader("API::NVdata") called at /usr/local/cpanel/Cpanel/LoadModule.pm line 67
Cpanel::LoadModule::loadmodule("API::NVdata") called at /usr/local/cpanel/Cpanel/API.pm line 142
Cpanel::API::_init_execute("NVdata", "get") called at /usr/local/cpanel/Cpanel/API.pm line 58
Cpanel::API::execute("NVdata", "get", HASH(0x55306b8)) called at /usr/local/cpanel/base/frontend/paper_lantern/basekit/activation.html.tt line 2
eval {...} called at /usr/local/cpanel/base/frontend/paper_lantern/basekit/activation.html.tt line 2
eval {...} called at /usr/local/cpanel/base/frontend/paper_lantern/basekit/activation.html.tt line 7
Template::Document::__ANON__(Template::Context=HASH(0x552b288)) called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Document.pm line 163
eval {...} called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Document.pm line 161
Template::Document::process(Template::Document=HASH(0x5558780), Template::Context=HASH(0x552b288)) called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Context.pm line 347
eval {...} called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Context.pm line 321
Template::Context::process(Template::Context=HASH(0x552b288), Template::Document=HASH(0x5558780)) called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Service.pm line 94
eval {...} called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template/Service.pm line 91
Template::Service::process(Template::Service=HASH(0x552ae38), "/usr/local/cpanel/base/frontend/paper_lantern/basekit/activat"..., HASH(0x559bb58)) called at /usr/local/cpanel/3rdparty/perl/514/lib64/perl5/cpanel_lib/x86_64-linux-64int/Template.pm line 66
Template::process(Template=HASH(0x5557f58), "/usr/local/cpanel/base/frontend/paper_lantern/basekit/activat"..., HASH(0x559bb58), SCALAR(0x3c171f8)) called at /usr/local/cpanel/Cpanel/Template.pm line 461
Cpanel::Template::process_template("cpanel", HASH(0x559bb58), HASH(0x55bdfc8)) called at cpanel.pl line 1139
main::cptt_exectag("/usr/local/cpanel/base/frontend/paper_lantern/basekit/activat"...) called at cpanel.pl line 5543
main::_parse_auto_template("/usr/local/cpanel/base/frontend/paper_lantern/basekit/activat"...) called at cpanel.pl line 5388
main::run_standard_mode() called at cpanel.pl line 831
Can anyone possibly give me any clues on what could be causing this and if I'm going about this the correct way?
-
Thanks for the quick reply. I'm just basing my idea's on what was in the original php plugin code: // LOAD CP MODULE TO GET CONFIG DATA //================================================================ $current_user_uid = $_CPANEL['USERDATA">['uid">; It's getting the $_CPANEL from the 'loadvars' internal call, I'm not sure how to emulate this in a Template Toolkit. 0 -
It seems I was missing 'USE Api 2;', so adding that has fixed the errors now. I've gone through the docs and cannot find any equivalent call in the Template Toolkit to load the same values as 'loadvars' from the '' php example. This will give me the details I need. 0
Please sign in to leave a comment.
Comments
3 comments