dotnetrix Posted January 14, 2017 Share Posted January 14, 2017 Hi, The developer docs state that it is possible to post from an Addon Module's tpl file to the module: For forms, use the POST form method to receive user input. Within the output function, the $_GET or $_POST variables can be checked. This can be used to display other output or perform various tasks, once links have been followed. My understanding of this is that, if I have: myaddonmod.tpl <form method="post" action="addonmodules.php?module=myaddonmod"> <input type="text" name="domain"><br> <input type="submit" name="submit" value="Submit Form"><br> </form> I am submitting to the module and should be able to capture it there: myaddonmod.php function myaddonmod_output($vars) { $modulelink = $vars['modulelink']; $domname = $_POST['domain']; *** do things to $domname *** } But this does not seem to work, running v7.1 Any help appreciated. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted January 15, 2017 Share Posted January 15, 2017 how your code looks like? 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted January 15, 2017 Share Posted January 15, 2017 So, the admin area itself cannot be templated. There's no documentation of this being supported at all. If that's what you're doing, you can't (at least as far as docs go). That said, it looks like you've got some confusion going on in your template.. Here's an updated version that will do what you want it to do. The addonmodule.tpl file {if $domain} {$domain} {else} <form method="post" action="index.php"> <input type="text" name="domain"><br> <input type="hidden" name="m" value="addonmodule"><br> <input type="submit" name="submit" value="Submit Form"><br> </form> {/if} Note that the {$domain} is checked, and that the options are a bit more clean Now, for the addon module code itself, an example addonmodule.php here: <?php function addonmodule_config() { $configarray = array( "name" => "Addom Module Information", "description" => "Addon Module Dummy", "version" => "0.1.5", "author" => "Tom Whiting<br /><a href=https://www.whmcs.guru>WHMCS Guru</a>", "language" => "english", "fields" => array( )); return $configarray; } function addonmodule_clientarea($vars) { if (!empty($_POST)) { $domain = $_POST['domain']; return array( 'pagetitle' => 'Addon Module', 'breadcrumb' => array('index.php?m=addonmodule'=>'Demo Addon'), 'templatefile' => 'addonmodule', 'requirelogin' => true, # accepts true/false 'forcessl' => false, # accepts true/false 'vars' => array( 'domain' => $domain, ), ); } if (empty($_POST)) { return array( 'pagetitle' => 'Addon Module', 'breadcrumb' => array('index.php?m=addonmodule'=>'Demo Addon'), 'templatefile' => 'addonmodule', 'requirelogin' => true, # accepts true/false 'forcessl' => false, # accepts true/false 'vars' => array( 'testvar' => 'demo', 'anothervar' => 'value', 'sample' => 'test', ), ); } } function addonmodule_output($vars) { if (!empty($_POST)) { print_r($_POST); } if (empty($_POST)) { print("<form method=\"post\" action=\"addonmodules.php\"> <input type=\"text\" name=\"domain\"><br> <input type=\"hidden\" name=\"module\" value=\"addonmodule\"><br> <input type=\"submit\" name=\"submit\" value=\"Submit Form\"><br> </form>"); } } ?> the difference: addonmodules.php is an admin area function, not a client side function 0 Quote Link to comment Share on other sites More sharing options...
dotnetrix Posted January 15, 2017 Author Share Posted January 15, 2017 Fantastic, thank you, this is exactly what I was looking for. 0 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.