2
In xoops_version.php, $modversion['blocks'][*]['options'] is a string containing a list of the default option values, separated by pipes (|).
In the block's show-function and edit-function, the parameter, customarily named $options, is an array whose elements are the current option values.
The show-function's purpose is to display the block's contents.
The edit-function's purpose is to return a string containing the HTML form fragment that's used for editing the block options on the Block Administration page.
Here's an example, from my chess module. There are two options: the maximum number of games displayed in the block, and a code (1,2 or 3) indicating which kind of games to display. The default values are 4 and 3, respectively.
xoops_version.php
...
// Blocks
$modversion['blocks'][1]['file'] = 'blocks.php';
$modversion['blocks'][1]['name'] = _MI_CHESS_GAMES;
$modversion['blocks'][1]['description'] = _MI_CHESS_GAMES_DES;
$modversion['blocks'][1]['show_func'] = 'b_chess_games_show';
// options: maximum number of games to display | 1=show games in play only/2=show concluded games only/3=show both
$modversion['blocks'][1]['options'] = '4|3';
$modversion['blocks'][1]['edit_func'] = 'b_chess_games_edit';
$modversion['blocks'][1]['template'] = 'chess_block_games.html';
blocks/blocks.php
function b_chess_games_show($options)
{
...
$limit = intval($options[0]); // sanitize with intval()
switch($options[1]) {
case 1:
$where = "pgn_result = '*'";
break;
case 2:
$where = "pgn_result != '*'";
break;
default:
$where = 1;
break;
}
...
function b_chess_games_edit($options)
{
$show_inplay = $options[1] == 1 ? "checked='checked'" : '';
$show_concluded = $options[1] == 2 ? "checked='checked'" : '';
$show_both = $options[1] == 3 ? "checked='checked'" : '';
$form = "
"._MB_CHESS_NUM_GAMES.": {$options[0]}' size='3' maxlength='3' />
$show_inplay /> "._MB_CHESS_SHOW_GAMES_INPLAY."
$show_concluded /> "._MB_CHESS_SHOW_GAMES_CONCLUDED."
$show_both /> "._MB_CHESS_SHOW_GAMES_BOTH."
";
return $form;
}
...
In this case the option values happen to be numbers, but they can be arbitrary strings.