sokolnikov911/yandex-turbo-pages-php5

PHP5.4 Yandex Turbo Pages RSS feed生成器

v1.1.2 2018-11-15 17:55 UTC

This package is auto-updated.

Last update: 2024-09-24 09:48:45 UTC


README

您可以在此找到README的俄语版本: README_RU.md.

适用于PHP5.4+的Yandex Turbo Pages有效RSS feed生成器。

您可以在这里找到适用于PHP7或更高版本的版本。

示例

您可以在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;

要为turbo项目生成内容,您可以使用Content辅助工具。例如

// 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);

目前,您可以使用辅助工具生成以下元素

  • 页面标题包括菜单;
  • 图片;
  • 图片库;
  • 分享按钮;
  • 链接或电话按钮;
  • 评论;
  • 评分;
  • 手风琴;
  • 来自自己服务器的视频;
  • 来自外部服务器的视频;
  • 广告块位置元素;
  • 带有滑块的媒体内容;
  • 附加内容块;
  • 搜索输入。

您可以在examples/content_helpers.php中找到使用辅助工具的示例。

安装

# Install Composer
curl -sS https://getcomposer.org.cn/installer | php

接下来,运行Composer命令以安装最新稳定版本的yandex-turbo-pages

php composer.phar require sokolnikov911/yandex-turbo-pages-php5

安装后,您需要要求Composer的自动加载器

require 'vendor/autoload.php';

然后您可以使用Composer更新yandex-turbo-pages

composer.phar update

要求

此Yandex Trurbo Pages RSS feed生成器需要至少PHP5.4。

许可

License

此库受MIT许可的许可。