PHP code example of migvitram / yii2-xml-generator
1. Go to this page and download the library: Download migvitram/yii2-xml-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
[
...
[
'loc' => Url::base(true) . 'your/pages/url',
'lastmod' => '2016-10-10', // date of page modification in format 'Y-m-d'
'changefreq' => migvitram\xmlgenerator\models\SitemapSchema::CHANG_FREQ_MONTH, // frequency of changing
'priority' => 0.8, // priority in double type number
],
...
]
use migvitram\xmlgenerator\models\schemas\Rss\RssSchema;
class Page extends Model
{
/**
* @return array
*/
public static function getItemsForRss()
{
// gather all needed news
return [
RssSchema::TITLE_FIELD => 'some title', // RssSchema constant for field name can be used
RssSchema::LINK_FIELD => 'soem link /',
RssSchema::DESCRIPTION_FIELD => 'description here',
'image' => [
'title' => 'aodfijoisdjf IMAGE',
'link' => Url::base(true).'/aodfijoisdjf987',
'url' => 'aodifj/asodifj.sod'
],
'language' => 'ru',
'items' => [
[
RssSchema::TITLE_FIELD => '1 title of entry',
RssSchema::LINK_FIELD => 'http://example.org/2003/12/13/atom03',
RssSchema::DESCRIPTION_FIELD => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
'someOption' => 'asdfoij'
],
[
RssSchema::TITLE_FIELD => '2 title of entry',
RssSchema::LINK_FIELD => 'http://example.org/2003/12/13/atom03',
RssSchema::DESCRIPTION_FIELD => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
'author' => 'ADFd Adfid',
],
[
RssSchema::TITLE_FIELD => '3 title of entry',
RssSchema::LINK_FIELD => 'http://example.org/2003/12/13/atom03',
RssSchema::DESCRIPTION_FIELD => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
'comments' => 'aodsfijoasidfjoij/aoidjsfoijadf/aoidsjf',
],
],
];
}
}
use migvitram\xmlgenerator\models\schemas\Atom\AtomSchema;
class Page extends Model
{
/**
* @return array
*/
public static function getItemsForAtom()
{
// gather all needed news
return [
'title' => 'Feed title',
'link' => 'your/site/url',
'updated' => '2020-04-10T11:50Z',
'author' => 'John Doe',
'id' => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
'items' => [
[
AtomSchema::ENTRY_TITLE_FIELD => '1 title of entry', // AtomSchema constant for field name can be used
AtomSchema::ENTRY_LINK_FIELD => 'http://example.org/2003/12/13/atom01',
AtomSchema::ENTRY_UPDATE_FIELD => '2016-10-10T6:50Z',
AtomSchema::ENTRY_SUMMARY_FIELD => 'Some summary about article',
AtomSchema::ENTRY_ID_FIELD => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
],
[
'title' => '2 title of entry',
'link' => 'http://example.org/2003/12/13/atom02',
'updated' => '2016-10-10T6:50Z',
'summary' => 'Some summary about article',
'id' => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
],
[
'title' => '3 title of entry',
'link' => 'http://example.org/2003/12/13/atom03',
'updated' => '2016-10-10T6:50Z',
'summary' => 'Some summary about article',
'id' => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
],
],
];
}
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.