rev Posted March 20, 2012 Share Posted March 20, 2012 Hi I'm trying to understand how i can get a variable on clientarea page from my addon module configuration. I've seen in documentation that this is the way. function my_custom_module_clientarea($vars) { $myvariable = $vars['myvariable']; } While in my custom module i have the following: function my_custom_mdoule_config() { $configarray = array( "name" => "My Module", "version" => "1.0", "author" => "My website", "description" => "Description", "language" => "english", "fields" => array( "myvariable" => array ("FriendlyName" => "myvariable", "Type" => "dropdown", "Options" => "1,2,3,4,5,6,7,8,9,10", "Description" => "This is my variable"), )); return $configarray; } function my_custom_module_output($vars) { $myvariable = $vars['myvariable']; } It is not working. What's the right way? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 20, 2012 Share Posted March 20, 2012 the _output() function in an addon module is for output in the admin area, not the client area. Regardless of that, simply assigning a variable like that isnt going to pass the variable along to your smarty templates. 0 Quote Link to comment Share on other sites More sharing options...
rev Posted March 20, 2012 Author Share Posted March 20, 2012 Thank you. I don't want to pass the variable to a tpl file. Setup > Addon Modules. I can customize my module from this page. For example i have 2 fields: width, height. I want to pass these variables to my_script.php in this way: <img src=something.png width=".$configarray['width']." height=".$configarray['height']."> 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 21, 2012 Share Posted March 21, 2012 Add this to the top of the _output function, it will be help troubleshoot what variables are available: print "<pre>"; var_dump($vars); print "</pre>"; 0 Quote Link to comment Share on other sites More sharing options...
rev Posted March 21, 2012 Author Share Posted March 21, 2012 Yep, i know. I can see all variables. I just need to pass these variables to a client area page. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 21, 2012 Share Posted March 21, 2012 As I said before, the _output function is not for the client area. That function is for returning code to the addon module page within the admin. 0 Quote Link to comment Share on other sites More sharing options...
rev Posted March 22, 2012 Author Share Posted March 22, 2012 Then i'm forced to use a mysql table thank you anyway 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 22, 2012 Share Posted March 22, 2012 or write a hook in your addon module and use the ClientAreaPage hook. Then you can just return the smarty variables to the client area and use them on any page you want. 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted March 22, 2012 Share Posted March 22, 2012 yes you have to access the db if you want to add it using a hook, but you use: get_query_val which is easy enough, search the docs for sql helpers that should get you started. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 22, 2012 Share Posted March 22, 2012 http://docs.whmcs.com/SQL_Helper_Functions get_query_val() is undocumented, but comes in handy if you only need to grab a single row/value. Saves you from having to call select_query() + mysql_fetch_array()/mysql_fetch_assoc() 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.