Skip to content

Instantly share code, notes, and snippets.

@Kobedinho
Last active November 9, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kobedinho/725f278c2a93cd19946ddbacc0ee125c to your computer and use it in GitHub Desktop.
Save Kobedinho/725f278c2a93cd19946ddbacc0ee125c to your computer and use it in GitHub Desktop.
package to create dropdown list
<?php
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
require_once('modules/ModuleBuilder/parsers/parser.dropdown.php');
function post_install()
{
global $app_list_strings, $current_language;
// dropdown list definition
$dropdownLists = array (
array (
"name" => "listName",
"list" => array(
"" => "",
"one" => "One",
"two" => "Two",
)
)
);
$_REQUEST['view_package'] = 'studio';
foreach ($dropdownLists as $list_data) {
$listEncode = encodeList($list_data['list']);
$list = "[".implode(",", $listEncode)."]";
$parserDropDown = new ParserDropDown();
$parserDropDown->saveDropDown(array(
'dropdown_lang' => $current_language,
'dropdown_name' => $list_data['name'],
'view_package' => 'studio',
'view_module' => '',
'list_value' => $list,
));
echo "<br> List saved: " . $list_data['name'];
}
}
function encodeList($list){
$listEncode = array();
foreach($list as $key => $item ){
$listEncode[] = <<<text
["$key","$item"]
text;
}
return $listEncode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment