Techsmith Posted April 4, 2017 Share Posted April 4, 2017 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. 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted April 4, 2017 Share Posted April 4, 2017 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 0 Quote Link to comment Share on other sites More sharing options...
Techsmith Posted April 5, 2017 Author Share Posted April 5, 2017 You can pass smarty variables to the admin area itselfTake 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. 0 Quote Link to comment Share on other sites More sharing options...
Techsmith Posted April 13, 2017 Author Share Posted April 13, 2017 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 -1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.