Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

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 return returns a list of fields will be shown in settings page.

Code Block
php
php

<?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.

 

Code Block
php
php

...

<?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:

Code Block
php
php

<?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);
       //..
    }
    //...
}

...

  • string
  • large_string
  • password
  • integer
  • boolean
  • currency
  • select
  • array
  • multi_text
  • multi_checkbox

string

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'string',
        'value'         => 'default_value',
    ],
];

large_string

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'large_string',
        'value'         => 'default_value',
    ],
];

password

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'password',
        'value'         => 'default_value',
    ],
];

integer

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'integer',
        'value'         => 10,
    ],
];

boolean

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'boolean',
        'value'         => 0,
    ],
];

currency

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'currency',
        'value'         => ['USD' => 0],
    ],
];

select

Code Block
php
php

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',
        ]
    ],
];

array

Code Block
php
php

return [
    [
        'var_name'      => 'example_name',
        'info'          => 'example label',
        'description'   => 'example description',
        'type'          => 'array',
        'value'         => [1,2,3,4],
    ],
];

multi_text

Code Block
php
php

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'
        ],
    ],
];

multi_checkbox

Code Block
php
php

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'
        ]
    ],
];