Jump to content

britnell

Members
  • Posts

    5
  • Joined

  • Last visited

britnell's Achievements

Newbie

Newbie (2/6)

2

Reputation

  1. Hi All, I'm new to developing in PHP and Processwire so apologies in advance for any stupid questions. I'm working on developing a module for the Twilio Channels API. I'd like to be able to input the API credentials into the modules settings page and then call the API credentials in module functions and, where necessary, in templates. I can currently add the API details and save them in my module config file, no problem. ModuleConfig file: <?php class TwilioChannelsConfig extends ModuleConfig { public function getDefaults() { return array( "id" => "", "token" => "", "from_number" => "" ); } public function getInputfields() { $inputfields = parent::getInputfields(); $f = $this->modules->get('InputfieldText'); $f->attr('name', 'id'); $f->label = $this->_('Twilio SID'); $f->notes = $this->_('From your Twilio Account (at https://www.twilio.com/user/account)'); $f->columnWidth = 50; $inputfields->add($f); $f = $this->modules->get('InputfieldText'); $f->attr('name', 'token'); $f->label = $this->_('Twilio API Token'); $f->columnWidth = 50; $inputfields->add($f); $f = $this->modules->get('InputfieldText'); $f->attr('name', 'from_number'); $f->label = $this->_('Your Twilio Number'); $f->description = $this->_('Will be used as the "from" number when sending messages or starting calls.'); $inputfields->add($f); return $inputfields; } } What I'd like to be able to do is either call getInputFields() in a template, something similar to this: $moduleConfig = $modules->get('TwilioChannelsConfig'); echo "<p>" . $moduleConfig->getInputFields('id') . "</p>"; or to call the credentials to my .module file. I've tried a few different approaches but can't get it to work. Not sure what I'm missing. Thanks in advance for any help.
  2. Hi Robin, it's working now I've put my functions in the module file, not the config file. Apologies for the stupid question and thanks for your help!
  3. To add to the previous reply. I've tried printing the module info in my template to confirm the install and I get $moduleInfo = $modules->getModuleInfo('TwilioChannelsConfig'); echo "<p>" . implode(" ", $moduleInfo) . "</p>"; and I get This is despite being able to edit the module settings via the admin page.
  4. Hi Autofahrn, thanks for replying. Yes, the module installs without error and allows me to enter details on the module settings page.
  5. Hi all, I'm new to Processwire and PHP. I'm trying to adapt a module I found which interacts with Twilio. I can install the module no problem and save settings but when calling a module function in a template I get the error: After getting similar errors with more complex functions I've tried simplifying the function as much as possible. My template is: and my .module file is: my module config file is: I've tried adding hi() to both the module config file and the .module file. I presume it needs to be in the .module file but neither work. Thanks in advance for any help given!
×
×
  • Create New...