<?xml version="1.0" encoding="UTF-8"?>
<!-- created with www.mysitemapgenerator.com -->
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://pres.ru.com/</loc>
<lastmod>2018-09-15T10:42:15+01:00</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://pres.ru.com/?id=1</loc>
<lastmod>2018-09-15T10:42:16+01:00</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://pres.ru.com/?id=2</loc>
<lastmod>2018-09-15T10:42:16+01:00</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://pres.ru.com/article/short/7</loc>
<lastmod>2018-09-15T10:42:26+01:00</lastmod>
<priority>0.6</priority>
</url>
</urlset>
$siteMap["url"][3]
//Формируем базовую часть ссылки
$baseLink = "https://pres.ru.com/article/short/";
$id = 7;
$linkNews = $baseLink.$id;
//Путь к карте сайта
$pathSiteMap = Yii::getAlias("@app")."\sitemap.xml";
//Открываем файл карты в режиме редактирования
$siteMap = simplexml_load_file($pathSiteMap);
print_r($siteMap);
SimpleXMLElement Object
(
[url] => Array
(
[0] => SimpleXMLElement Object
(
[loc] => https://pres.ru.com/
[lastmod] => 2018-09-15T10:42:15+01:00
[priority] => 1.0
)
[1] => SimpleXMLElement Object
(
[loc] => https://pres.ru.com/?id=1
[lastmod] => 2018-09-15T10:42:16+01:00
[priority] => 1.0
)
[2] => SimpleXMLElement Object
(
[loc] => https://pres.ru.com/?id=2
[lastmod] => 2018-09-15T10:42:16+01:00
[priority] => 1.0
)
[3] => SimpleXMLElement Object
(
[loc] => https://pres.ru.com/article/short/7
[lastmod] => 2018-09-15T10:42:26+01:00
[priority] => 0.6
)
}
'urlManager' => [
'enablePrettyUrl' => true, // Включаем компонент
'showScriptName' => false,// Исключаем точку входа (index.php) из ссылок
'rules' => [ // Описываем шаблоны url и соответсвующие им контроллеры и действия
// Массив маршрутов
'/' => 'site/index',
/* "admin/tizer/delete/<id:\d+>" => "admin/tizer/delete",
*/ 'article/short/<id:\d+>' => 'site/article/',
'article/full/<id:\d+>' => 'site/fullarticle/',
'addClick/<idClickBlock:\d+>' => 'site/addclick',
'admin' => 'admin/default',
'admin/news' => 'admin/news',
'admin/tizers' => 'admin/tizer',
'admin/sections' => 'admin/section',
'admin/users' => 'admin/user',
'<_m:\w+>/<_c:\w+>/<_a:\w+>' => '<_m>/<_c>/<_a>'
],
],
public function beforeAction($action)
{
return true;
}
'<_m:\w+>/<_c:\w+>/<_a:\w+>' => '<_m>/<_c>/<_a>
public function beforeAction($action)
{
print_r($action);
return false;
}
/*public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}*/
public function behaviors()
{
return [
TimestampBehavior::className()
];
}
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
'rules' => [ // Описываем шаблоны url и соответсвующие им контроллеры и действия
// Массив маршрутов
'/' => 'site/index',
/* "admin/tizer/delete/<id:\d+>" => "admin/tizer/delete",
*/ 'article/short/<id:\d+>' => 'site/article/',
'article/full/<id:\d+>' => 'site/fullarticle/',
'addClick/<idClickBlock:\d+>' => 'site/addclick',
'admin' => 'admin/default',
'admin/news' => 'admin/news',
'admin/tizers' => 'admin/tizer',
'admin/sections' => 'admin/section',
'admin/users' => 'admin/user',
],
<?php
namespace app\modules\admin\models;
use Yii;
/**
* This is the model class for table "users".
*
* @property string $id
* @property string $username
* @property string $email
* @property string $password
* @property integer $created_at
*/
class Users extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'users';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['username', 'email', 'password', 'created_at'], 'required'],
[['created_at'], 'integer'],
['email','email'],
[['username', 'password'], 'string', 'max' => 50],
[['email'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'username' => 'Имя пользователя',
'email' => 'Email',
'password' => 'Пароль',
'created_at' => 'Дата регистрации',
];
}
}
$siteMap->asXml($this->pathSiteMap);