I'm tweaking a module of mine (SocialTwitterFeed) to do something else and need to have an ASMSelect in the config screen -this bit is simple enough, however how do I limit it so the user can only select ONE page?
Here's the current code:
private static function _createInputfieldASMSelect($aName, $aTitle, $aValue, $aDesc='', $aPath='/') {
if(!isset($aValue) || !is_array($aValue)) $aValue = array();
$modules = Wire::getFuel('modules');
$field = $modules->get("InputfieldAsmSelect");
$field->attr('name', $aName);
$children = wire('pages')->get($aPath)->children;
foreach($children as $child) {
$field->addOption($child->id, $child->title);
}
$field->attr('value', $aValue);
$field->label = $aTitle;
$field->description = $aDesc;
return $field;
}In this case, it's being used to select a field, so here's the more relevant code that works, but currently selects multiple fields instead of just one:
private static function _createInputfieldASMFieldSelect($aName, $aTitle, $aValue, $aDesc='', $aPath='/') {
if(!isset($aValue) || !is_array($aValue)) $aValue = array();
$modules = Wire::getFuel('modules');
$field = $modules->get("InputfieldAsmSelect");
$field->attr('name', $aName);
$children = wire('fields')->find('id>1');
foreach($children as $child) {
$field->addOption($child->id, $child->name);
}
$field->attr('value', $aValue);
$field->label = $aTitle;
$field->description = $aDesc;
return $field;
}I posted both as thought the latter might be useful to someone already familiar with the former, and I'd be interested to see if there are any major differences required for the two.
Cheers!
Oh, and the addition is going to be that you can specify a field for the module so that you can enter a customised message for a given news item/article/whatever to accompany the title and link in the twitter post on a per-page basis rather than the blanket default message in the current version - though it'll fall back to the default message if no custom message is selected.
Getting complicated, but very configurable












