sokolnikov911 / yandex-turbo-pages-php5
PHP5.4 Yandex Turbo Pages RSS feed generator
Installs: 10 046
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 4
Forks: 1
Open Issues: 2
Requires
- php: >=5.4
- ext-mbstring: *
Requires (Dev)
- mockery/mockery: ~0.9.9
- phpunit/phpunit: ~4.8.9
README
Russian version of README you can find here: README_RU.md.
Yandex Turbo Pages valid RSS feed generator for PHP5.4+.
Version for PHP7 or later you can find here.
Examples
This example you can find in examples/example.php
// creates Feed with all needed namespaces $feed = new Feed(); // creates Channel with description and one ad from Yandex Ad Network $channel = new Channel(); $channel ->title('Channel Title') ->link('http://blog.example.com') ->description('Channel Description') ->language('ru') ->adNetwork(Channel::AD_TYPE_YANDEX, 'RA-123456-7', 'first_ad_place') ->appendTo($feed); // adds Google Analytics to feed $googleCounter = new Counter(Counter::TYPE_GOOGLE_ANALYTICS, 'XX-1234567-89'); $googleCounter->appendTo($channel); // adds Yandex Metrika to feed $yandexCounter = new Counter(Counter::TYPE_YANDEX, 12345678); $yandexCounter->appendTo($channel); // creates first page of feed with link and enabled turbo, description and other content, and appends this page to channel $item = new Item(); $item ->title('Thirst page!') ->link('http://www.example.com/page1.html') ->author('John Smith') ->category('Technology') ->turboContent('Some content here!<br>Second content string.') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->appendTo($channel); // creates list of related pages $relatedItemsList = new RelatedItemsList(); // adds link to first related page $relatedItem = new RelatedItem('Related article 1', 'http://www.example.com/related1.html'); $relatedItem->appendTo($relatedItemsList); // adds link to second related page with image $relatedItem = new RelatedItem('Related article 2', 'http://www.example.com/related2.html', 'http://www.example.com/related2.jpg'); $relatedItem->appendTo($relatedItemsList); // appends list of related links to first page $relatedItemsList ->appendTo($item); // creates another one page with disabled turbo $item = new Item(false); $item ->title('Second page!') ->link('http://www.example.com/page2.html') ->author('John Smith') ->category('Technology') ->turboContent('Yet another content here!') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->appendTo($channel); // displays the generated feed echo $feed;
For generating content for turbo items you can use Content
helper. For example:
// generate header $menuArray = [ ['url' => 'http://example/page1.html', 'title' => 'Page title 1'], ['url' => 'http://example/page2.html', 'title' => 'Page title 2'] ]; $header = Content::header('Main title', 'Second title', 'http://example.com/image1.jpg', 'Image description', $menuArray);
At this time you can use helpers for generate next elements:
- page header including menu;
- image;
- images gallery;
- share buttons;
- link or phone button;
- comments;
- rating;
- accordion;
- video from own server;
- video from external server;
- ad block position element;
- media-content with slider;
- additional content block;
- search input.
Examples of using helpers you can find in examples/content_helpers.php
.
Installing
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of yandex-turbo-pages
php composer.phar require sokolnikov911/yandex-turbo-pages-php5
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update yandex-turbo-pages using composer:
composer.phar update
Requirements
This Yandex Trurbo Pages RSS feed generator requires at least PHP5.4.
License
This library is licensed under the MIT License.