chub / timelinejs-bundle
此包最新版本(dev-master)没有可用的许可信息。
TimelineJS bundle for Symfony2
dev-master / 2.2.x-dev
2013-03-16 11:34 UTC
Requires
- php: >=5.3.3
- symfony/framework-bundle: 2.2.*
- symfony/yaml: 2.2.*
This package is not auto-updated.
Last update: 2024-09-14 13:18:06 UTC
README
TimelineJS Symfony2 扩展包。提供方便地集成 TimelineJS 的方式。
关于 TimelineJS
网上有很多时间轴工具,但它们几乎都是要么看起来不舒服,要么难以使用。创建既美观又直观的时间轴。
安装
下载扩展包
首先,使用以下常见方法之一下载扩展包
使用依赖文件
将以下行添加到您的 deps
文件中,并运行 php bin/vendors install
[TimelineJSBundle]
git=https://github.com/ChubV/TimelineJSBundle.git
target=bundles/ChubProduction/TimelineJSBundle
使用 Composer
注册命名空间
将以下命名空间条目添加到您的自动加载器中的 registerNamespaces
调用中
<?php // app/autoload.php $loader->registerNamespaces(array( // ... 'ChubProduction\TimelineJSBundle' => __DIR__.'/../vendor/bundles', // ... ));
如果您使用的是 Composer 自动生成的自动加载文件,则此步骤是不必要的
注册扩展包
要开始使用扩展包,请将其注册到您的 Kernel 中
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ChubProduction\TimelineJSBundle\TimelineJSBundle(), ); // ... }
创建您的第一个时间轴
创建一个实现 TimelineEntityInterface 的实体
<?php // TimelineEntity.php // ... class TimelineEntity implements TimelineEntityInterface { // ... }
获取您的实体数组
数组将代表您时间轴上的点。创建时间轴并将其传递到您的视图中。
<?php // TimelineController.php // ... /** * @Route("/timeline", name="_timeline") * @Template() */ public function timelineAction() { $ts = $this->get('timelinejs'); $timeline = $ts->createTimeline('myTimeline', $this->fetchTimelineEntities()); return compact('timeline'); }
在模板中渲染时间轴
{# timeline.html.twig #} {% import "TimelineJSBundle::macro.html.twig" as t %} {{ t.head() }} <div id="timeline"></div> {{ t.show(timeline, {'embed_id': 'timeline', 'debug': true}) }}