Jump to content

Addon Module call template help


Techsmith

Recommended Posts

I have been trying to do the good old search and have found plenty of ways of doing what I want... just not where I want to do it, so I finally got to the point of just reaching out to the community.

 

I am looking at developing an addon and for the most part everything seems simple enough although I am trying to use an template file for part of the admin output and i'm struggling to achieve what I want.

 

The documentation (https://developers.whmcs.com/addon-modules/admin-area-output/) mentions:

"Things aren’t limited to just one file. Use the _output function to include other files, call templates, etc. The system is flexible."

 

which I took to mean that I can call a smarty template .tpl file although currently I am at a loss as to how I should be calling it, can anyone give me a quick couple of lines as to whether "templates" actually means smarty templates and how I should make the call.

 

Something crude like:

$thepage = file_get_contents('/home/user/public_html/dev/modules/addons/theaddon/admin/admin.tpl');

echo $thepage;

 

works for displaying html although i'd prefer to be able to:

pass {$smarty} variables.

Keeping design and functionality separate.

 

Appreciate any direct examples, ideas or just pointers in the right direction.

Link to comment
Share on other sites

You can pass smarty variables to the admin area itself

Take a look at AdminAreaPage, this is an excellent way to assign smarty variables to the system. You can most likely assign the template page there too, though I haven't tried doing that, specifically

 

Thanks for trying to help although I guess my title is a little misleading as I am not trying to hook into the admin area, I am trying to work with an Addon modules blog_output($vars) and call a template rather than just echo ''; my presentation where I would prefer to keep just functionality.

Link to comment
Share on other sites

  • 2 weeks later...

So for anyone else scratching their head, passing everything statically obviously wasn't sitting well with me so echo $theHtmlFile; was never going to be a "proper" solution.

 

Seeing as I already had access to smarty for right or wrong I ended up going with the following in order to use templates that are able to use smarty variables:

 

   $smarty = new Smarty();
   $smarty->assign('version', $vars['version']);
   $smarty->assign('otherVars', 'thatYouNeed');
   $smarty->caching = false;
   $smarty->compile_dir = $GLOBALS['templates_compiledir'];
   $smarty->display(dirname(__FILE__) . '/admin/admin.tpl');

 

To give full credit where credit is due I finally used an obscure enough search term to get a stackoverflow question from 2013 and the above is identical (functionally) to the answer given by Akahadaka.

http://stackoverflow.com/questions/14246279/whmcs-addon-module-admin-section-template

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated