Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpalourdio/twitterwidgetbundle
Twig extension to easily display twitter embedded timelines widgets
https://github.com/mpalourdio/twitterwidgetbundle
bundle symfony symfony-bundle symfony3 symfony3-bundle timeline-widget twig twig-extension twitter
Last synced: about 1 month ago
JSON representation
Twig extension to easily display twitter embedded timelines widgets
- Host: GitHub
- URL: https://github.com/mpalourdio/twitterwidgetbundle
- Owner: mpalourdio
- License: mit
- Created: 2014-10-03T09:59:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-29T09:12:49.000Z (almost 6 years ago)
- Last Synced: 2024-10-13T06:22:18.085Z (about 1 month ago)
- Topics: bundle, symfony, symfony-bundle, symfony3, symfony3-bundle, timeline-widget, twig, twig-extension, twitter
- Language: PHP
- Homepage: https://github.com/mpalourdio/TwitterWidgetBundle
- Size: 22.5 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/mpalourdio/TwitterWidgetBundle.svg?branch=master)](https://travis-ci.org/mpalourdio/TwitterWidgetBundle)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpalourdio/TwitterWidgetBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpalourdio/TwitterWidgetBundle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/mpalourdio/TwitterWidgetBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mpalourdio/TwitterWidgetBundle/?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/55cdf6c4-bdcb-423a-bd3e-20dda3f8ad13/mini.png)](https://insight.sensiolabs.com/projects/55cdf6c4-bdcb-423a-bd3e-20dda3f8ad13)
[![PHP 7.0+][ico-engine]][lang]
[![MIT Licensed][ico-license]][license][ico-engine]: http://img.shields.io/badge/php-7.0+-8892BF.svg
[lang]: http://php.net
[ico-license]: http://img.shields.io/packagist/l/adlawson/veval.svg
[license]: LICENSETwitterWidgetBundle
===================
Twig extension to easily display twitter embedded timelines widgets in Symfony project. Based on this library : https://github.com/mpalourdio/TwitterWidgetsRequirements
============
PHP 7.0+ - Only Composer installation supportedInstallation
============
Run the command below to install via Composer```shell
composer require mpalourdio/twitter-widget-bundle
```Add ```new TwitterWidgetBundle\TwitterWidgetBundle()``` to your **AppKernel.php**
Usage
=====
- 1) Create a timeline widget here : https://twitter.com/settings/widgets/new
- 2) In the javascript generated code, get the URL and the data-widget-id (minimum information required)
- 3) Finally, in a twig template, use as following:```php
{{
tw({
'dataWidgetId' : '1245687955000', => the id must be a string (quotes), because of long integer converted to float
'href' : 'https://twitter.com/NickName',
'hrefText' : 'Here type a title'
},
true/false
}}
```All the following options are handled : https://dev.twitter.com/web/embedded-timelines#options
Their PHP equivalent as array keys to use in the twig function are :
```php
'class' => 'A css class, by default it will be twitter-timeline',
'href' => 'The link to the timeline',
'hrefText' => 'A title for your timeline to display',
'dataWidgetId' => 'Your data widget ID : must be a string (!)',
'dataTheme' => 'ex: dark',
'dataLinkColor' => 'ex: #cc0000',
'width' => 300 (integer),
'height' => 400 (integer),
'dataChrome' => 'noheader nofooter noborders noscrollbar transparent', => a string with options separated by a single space
'dataBorderColor' => 'border color used by the widget',
'language' => 'The widget language detected from the page, based on the HTML lang attribute of your content. You can also set the HTML lang attribute on the embed code itself.',
'dataTweetLimit' => 20,
'dataRelated' => 'benward,endform',
'dataAriaPolite' => 'polite or assertive',
```You can give an instance of ```TwitterWidgets\Options\WidgetOptions``` instead of an array (or any implementation of ```TwitterWidgets\Timeline\WidgetOptionsInterface```).
```php
$options = new TwitterWidgets\Options\WidgetOptions();
$options->setDataWidgetId('1245687955000');
$options->setHref('https://twitter.com/NickName');
$options->setHrefText('Here type a title');{{ tw(options) }}
```The function second parameter is a boolean (true by default), that indicates if you must render the javascript code for your widget. If you have more that one widget on your page,
use the ```OneTimeJs``` extension to only add once the javascript code, just before your ```