, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist mice-tm/yii2-timeline-widget "*"
or add, (*4)
"mice-tm/yii2-timeline-widget": "*"
to the require section of your composer.json
file., (*5)
Usage
Timeline widget expects array of LogModel-like models (micetm\timeline\LogModel) in items
-param.
Where title
and body
can contain macros strings in yii macros-format {here-is-macros}
.
With eventIcons
-param you can extend or reassign icons for actions., (*6)
class LogModel extends Model
{
public $action;
public $title,
public $body;
public $log_date;
public $macros;
public $_id;
public function rules()
{
return [
[['action', 'title'], 'required'],
[['action', 'title', 'body'], 'string'],
['log_date', 'integer'],
['macros', 'safe']
];
}
public function attributes()
{
return [
'_id',
'action',
'title',
'body',
'macros',
'log_date',
];
}
public function attributeLabels()
{
return [
'_id' => '#',
'action' => 'Action',
'macros' => 'Macros',
'title' => 'Title',
'body' => 'Body',
'log_date' => 'Date',
];
}
}
Once the extension is installed, simply use it in your code by :, (*7)
$dataProvider->getModels(),
'eventIcons' => [
'update' => 'fa fa-pencil bg-orange',
'add' => 'fa fa-pencil bg-orange',
'create' => 'glyphicon glyphicon-star bg-green',
]
]); ?>