britnell
-
Posts
5 -
Joined
-
Last visited
Posts posted by britnell
-
-
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!-
1
-
-
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
QuoteNotice: Array to string conversion in /opt/lampp/htdocs/processwire/site/templates/twiliochannels.php on line 7
0 TwilioChannelsConfig 0 0.0.0 Inactive Array Array Array Array 0 Unable to locate module
This is despite being able to edit the module settings via the admin page.
-
Hi Autofahrn, thanks for replying.
Yes, the module installs without error and allows me to enter details on the module settings page. -
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:QuoteFatal error: Uncaught Error: Call to a member function hi() on null in /opt/lampp/htdocs/processwire/site/templates/twiliochannels.php:18 Stack trace: #0
After getting similar errors with more complex functions I've tried simplifying the function as much as possible.
My template is:
Quote<?php namespace ProcessWire;include('./_head.php'); ?><div id='content'><?php$module = $modules->get('TwilioChannelsConfig');echo "<p>" . $module->hi() . "</p>";?></div>and my .module file is:
Quoteclass TwilioChannels extends WireData implements Module, ConfigurableModule {
public function init() {
}
}my module config file is:
Quote<?phpclass TwilioChannelsConfig extends ModuleConfig {public function hi() {return "Hi there ";}}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!
Twilio Channels Module: Using Module Config Variables in .module file and templates
in Dev Talk
Posted
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:
What I'd like to be able to do is either call getInputFields() in a template, something similar to this:
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.