Last active
November 9, 2016 17:54
-
-
Save Kobedinho/725f278c2a93cd19946ddbacc0ee125c to your computer and use it in GitHub Desktop.
package to create dropdown list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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