vivekmarakana/yii2-timeline-widget

Timeline/Telemetry Widget for Yii2

Installs: 3 435

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 7

Open Issues: 0

Type:yii2-extension

dev-master 2020-09-10 08:47 UTC

This package is auto-updated.

Last update: 2022-11-10 13:14:06 UTC


README

Total Downloads Monthly Downloads License

Timeline/Telemetry Widget for Yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist vivekmarakana/yii2-timeline-widget "*"

or add

"vivekmarakana/yii2-timeline-widget": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php
    $items = [];
    foreach ($posts as $post) {
        $data = [];
        $data['title'] = $post->title;
        $data['date'] = \Yii::$app->formatter->asDate(date("Y-m-d H:i:s", strtotime('+330 minutes', strtotime($post->published_at))), 'php:d M,Y');
        $data['time'] = \Yii::$app->formatter->asDate(date("Y-m-d H:i:s", strtotime('+330 minutes', strtotime($post->published_at))), 'php:h:i A');
        $data['notes'] = $post->summary;

        if(!is_null($post->postedBy)) {
            $data['subtitle'] = "By {$post->postedBy->name} - {$post->postedBy->bio}";
        }

        $items[] = $data;
    }
    \vivekmarakana\widgets\Timeline::widget(['items' => $items]);
?>