Requires: phpFox version 4.6.0 or higher.
phpFox allows admin to configure component blocks by using Block Settings.
Example, admin can configure how many item will be shown, and visibility of this block, etc...
In order to add ability, add new method getSettings()
to your block, this method returns a list of fields shown in settings page.
<?php class Friend_Component_Block_Mini extends Phpfox_Component //.. /** * Settings of block * @return array */ public function getSettings() { return [ [ 'info' => _p('friend_block_mini_limit_info'), 'description' => _p('friend_block_mini_limit_description'), 'value' => 7, 'var_name' => 'limit', 'type' => 'integer', ] ]; } //.. ?> |
Field
Visibility
is prepended before your settings field automatically.
In case you would like to validate input value, add method getValidation
to your class.
<?php class Fiend_Component_Block_Mini extends Phpfox_Component { // ... /** * Get array of validation rules */ public function getValidation(){ return [ 'limit'=> [ 'def' => 'int:required', 'min' => 0, 'title'=>'Invalid number' ] ]; } //... } |
In order to get configured value:
<?php class Fiend_Component_Block_Mini extends Phpfox_Component { public function process(){ /** * return configured value or "7" if the value is empty. * */ $iLimit = $this->getParam('limit',7); //.. } //... } |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'string', 'value' => 'default_value', ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'large_string', 'value' => 'default_value', ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'password', 'value' => 'default_value', ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'integer', 'value' => 10, ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'boolean', 'value' => 0, ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'currency', 'value' => ['USD' => 0], ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'select', 'value' => 'value_1', 'options' => [ 'value_1' => 'Value Label 1', 'value_2' => 'Value Label 2', ] ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example label', 'description' => 'example description', 'type' => 'array', 'value' => [1,2,3,4], ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example_label', 'description'=>'example description', 'type'=> 'multi_text', 'value'=> [ 'key1' =>'example value 1', 'key2' =>'example value 2', 'key3'=>'example value 3' ], ], ]; |
return [ [ 'var_name' => 'example_name', 'info' => 'example labele', 'description' => 'example description', 'type' => 'multi_checkbox', 'value' => ['value_1', 'value_2'], 'options' => [ 'value_1' => 'Value Label 1', 'value_2' => 'Value Label 2', 'value_3' => 'Value Label 3' ] ], ]; |