As of Blesta 4.11, plugins can define info cards in the client profile, both in the client area and in the staff area. These cards are quite flexible which makes them quite useful, they can be anything from a simple counter to a complex card with custom HTML code.
Plugin Cards in the client area.
Plugin Cards in the staff area.
Registering Cards
Plugin cards can be registered both in the client area and in the staff area. Let's look at an example.
class MyPluginPlugin extends Plugin { ... public function getCards() { return [ [ 'level' => 'client', 'callback' => ['this', 'getOrdersCount'], 'callback_type' => 'value', 'text_color' => '#ebebeb', 'background' => '#343a40', 'background_type' => 'color', 'label' => 'OrderPlugin.card_client.orders', 'link' => 'order/orders/', 'enabled' => 1 ] ]; } public function getOrdersCount($client_id) { return $this->OrderOrders->getListCount('accepted', ['client_id' => $client_id]); } ... }
Parameter | Type | Description |
---|---|---|
level | string | Where the card should be displayed, it can be 'client' or 'staff'. |
callback | array | An array containing as key the name of the class and as value the name of the method to call to obtain the information to show in the card. Use 'this', if the method to call belongs to the current Plugin class, in this example "MyPluginPlugin". |
callback_type | string | The type returned by the method defined in the callback, it can be 'value' if the card is a counter and the callback returns an integer and 'html' if the callback returns the a custom html code of the card. |
text_color | string | The color of the text inside the card, it can be in hexadecimal or RGB. It is only available if callback_type is equal to 'value'. |
background | string | The color in hexadecimal or RGB, or a url to an image to use as background. It is only available if callback_type is equal to 'value'. |
background_type | string | The type of background the card will use, it can be 'color' or 'image'. It is only available if callback_type is equal to 'value'. |
label | string | The label of the card. |
link | string | The link of the card. |
enabled | integer or boolean | Whether the card will be activated by default during installation or not, it can be '1' or true to activate it by default, or '0' or false to create it deactivated. |