Gayan Virajith Posted November 7, 2013 Share Posted November 7, 2013 Hello Processwire, First of all thank you for a wonderful CMS. This would be my first question to the Processwire community as I started with it. I am trying to create module which can keep site logo as a configurable input field. I use following code to create InputFieldImage and still no luck. public static function getModuleConfigInputfields(array $data) { $field = wire('modules')->get('InputfieldImage'); $field->name = 'siteLogo'; $field->label = "Site Logo"; $field->maxFiles = 1; if(isset($data['siteLogo'])) $field->value = $data['siteLogo']; $inputfields->add($field); return $inputfields; } Any advise will be greatly appreciated. Thanks again. 1 Link to comment Share on other sites More sharing options...
RyanJ Posted November 7, 2013 Share Posted November 7, 2013 Are you defining $inputfields somewhere? Link to comment Share on other sites More sharing options...
Soma Posted November 7, 2013 Share Posted November 7, 2013 Adding file fields to module config isn't possible. well it is but wouldn't work. Link to comment Share on other sites More sharing options...
Gayan Virajith Posted November 8, 2013 Author Share Posted November 8, 2013 Thanks Soma and RJay. This would be my module script: class SiteSettings extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( 'title' => 'Site settings', 'version' => 0.01, 'summary' => 'Store general site settings', 'author' => 'Gayan Virajith', 'singular' => true, 'autoload' => true, ); } static public function getDefaultData() { return array( 'siteLogo' => '', ); } public function __construct() { foreach(self::getDefaultData() as $key => $value) { $this->$key = $value; } } public function init() { //do it later } public static function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); // ask site logo image $field = wire('modules')->get('InputfieldImage'); $field->name = 'siteLogo'; $field->label = "Site Logo"; $field->maxFiles = 1; if(isset($data['siteLogo'])) $field->value = $data['siteLogo']; $inputfields->add($field); return $inputfields; } } I have attached module preview as well. According to Soma's advise, I have to give up. Thanks every one. 1 Link to comment Share on other sites More sharing options...
ryan Posted November 9, 2013 Share Posted November 9, 2013 In order to store a file, you need to associate it with a page. Each page has a dedicated location where it can store files. In your case, it may be better to accomplish the functionality you are after with a template (and a page using that template) rather than a module. Though if you wanted it to be a module, you could always create it as a Process module that can handle uploaded files. The ImportPagesCSV module is an example of that. But I honestly think the simplest path is to use a template. 4 Link to comment Share on other sites More sharing options...
Gayan Virajith Posted November 11, 2013 Author Share Posted November 11, 2013 Thank you Ryan. I appreciate your advise. Link to comment Share on other sites More sharing options...
Hari KT Posted July 14, 2014 Share Posted July 14, 2014 Hi Ryan, this is an interesting functionality which PW can have or may need, like every website has some sort of settings. One question is whether we can create a select of type ASM in the module configuration ? 1 Link to comment Share on other sites More sharing options...
Soma Posted July 14, 2014 Share Posted July 14, 2014 Sure you can, or pw can. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now