Jump to content
Dipta Dhar

how to access module hook to myModule_ConfigOptions data

Recommended Posts

myModule.php:

function myModule_ConfigOptions(array $params) {
    
    $conf = array(
		/*  configoption1   */
        "protocol" => array(
            "FriendlyName" => "Protocol Type",
            "Type" => "dropdown",
            "Options" => "http,https",
            "Size" => "25",
            "Description" => "enter protocol type"),
		
		/*  configoption2   */
        "host" => array(
            "FriendlyName" => "Host Name",
            "Type" => "text",
            "Size" => "25",
            "Description" => "enter host name address",
            "Default" => "127.0.0.1") 
    );
    
    return $conf;
}

 

hooks.php:

<?php

add_hook('...........', $priority, function($vars) {
  
	$protocol = <....?....>["configoption1"];
    $host     = <....?....>["configoption2"];
  
  	/*
    	How can you received configoption options data
        in modules hook.
    */
}

?>

NB: How can you received configoption options data in modules hook.

Share this post


Link to post
Share on other sites
On 11/12/2020 at 10:36 AM, Dipta Dhar said:

 

NB: How can you received configoption options data in modules hook.

You can't.
It's crazy, but you can't do it directly and easily.

 

The only way: recover the parameter value from the db, using something like this:

$mymoduleparameter = Capsule::table('tbladdonmodules')->where('setting','mymoduleparameter')->value('value');

 

Share this post


Link to post
Share on other sites

Would be best to add on:

->where('module', $modulename )

to the query to limit to just your module. 

Share this post


Link to post
Share on other sites
On 11/17/2020 at 9:16 PM, steven99 said:

Would be best to add on:


->where('module', $modulename )

to the query to limit to just your module. 

You're right!

(I have the habit to name module variables as $ModulenameModulevariable , so it's almost impossible going wrong ... 😉 )

Share this post


Link to post
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