Skip to content

Commit

Permalink
Added a timeline widget (Close #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fps01 committed Jul 6, 2016
1 parent 846843a commit 0f60293
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Yii2 Gentelella Change Log
1.2.0 under development
-----------------------

- New #8: Added a `yiister\gentelella\widgets\Timeline` widget (fps01)
- New #5: Added an ability to keep a sidebar state (fps01)
- Fix #6: using a PHP 5.4 instead of 5.5

Expand Down
51 changes: 51 additions & 0 deletions widgets/Timeline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2015 Yiister
* @license https://github.com/yiister/yii2-gentelella/blob/master/LICENSE
* @link http://gentelella.yiister.ru
*/

namespace yiister\gentelella\widgets;

use yii\base\Widget;
use yii\helpers\Html;

class Timeline extends Widget
{
/**
* @var array the HTML attributes for the widget container tag
*/
public $options = ['class' => 'list-unstyled timeline widget'];

/**
* @var array the list of items to render
* Each item allows the next string attributes:
* title - the header of item
* byline - the string with time and author
* content - the main item content
*/
public $items = [];

public function run()
{
echo Html::beginTag('ul', $this->options);
foreach ($this->items as $item) {
echo Html::beginTag('li');
echo Html::beginTag('div', ['class' => 'block']);
echo Html::beginTag('div', ['class' => 'block-content']);
if (isset($item['title'])) {
echo Html::tag('h2', $item['title'], ['class' => 'title']);
}
if (isset($item['byline'])) {
echo Html::tag('div', $item['byline'], ['class' => 'byline']);
}
if (isset($item['content'])) {
echo Html::tag('div', $item['content'], ['class' => 'excerpt']);
}
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('li');
}
echo Html::endTag('ul');
}
}

0 comments on commit 0f60293

Please sign in to comment.