Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
eb510db1
Commit
eb510db1
authored
Mar 21, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1097 - Создать Sitemap специально для яндекс
parent
e95e07f8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
3 deletions
+29
-3
frontend/config/main.php
frontend/config/main.php
+1
-0
frontend/modules/sitemap/Sitemap.php
frontend/modules/sitemap/Sitemap.php
+3
-2
frontend/modules/sitemap/controllers/DefaultController.php
frontend/modules/sitemap/controllers/DefaultController.php
+24
-0
frontend/modules/sitemap/views/default/index.php
frontend/modules/sitemap/views/default/index.php
+1
-1
No files found.
frontend/config/main.php
View file @
eb510db1
...
...
@@ -163,6 +163,7 @@ return [
'rules'
=>
[
'contacts'
=>
'site/contacts'
,
[
'pattern'
=>
'sitemap'
,
'route'
=>
'sitemap/default/index'
,
'suffix'
=>
'.xml'
],
[
'pattern'
=>
'sitemapg'
,
'route'
=>
'sitemap/default/google'
,
'suffix'
=>
'.xml'
],
''
=>
'content/page/view'
,
'reviews'
=>
'reviews/review/index'
,
...
...
frontend/modules/sitemap/Sitemap.php
View file @
eb510db1
...
...
@@ -59,7 +59,7 @@ class Sitemap extends Module
* @return string
* @throws \yii\base\InvalidConfigException
*/
public
function
buildSitemap
()
public
function
buildSitemap
(
$links
=
false
)
{
$urls
=
$this
->
urls
;
...
...
@@ -85,7 +85,8 @@ class Sitemap extends Module
$sitemapData
=
$this
->
createControllerByID
(
'default'
)
->
renderPartial
(
'index'
,
[
'urls'
=>
$urls
,
'langs'
=>
$langs
'langs'
=>
$langs
,
'links'
=>
$links
]);
$this
->
cacheProvider
->
set
(
$this
->
cacheKey
,
$sitemapData
,
$this
->
cacheExpire
);
...
...
frontend/modules/sitemap/controllers/DefaultController.php
View file @
eb510db1
...
...
@@ -39,4 +39,28 @@ class DefaultController extends Controller
return
$sitemapData
;
}
public
function
actionGoogle
()
{
/** @var \himiklab\sitemap\Sitemap $module */
$module
=
$this
->
module
;
if
(
!
$sitemapData
=
$module
->
cacheProvider
->
get
(
$module
->
cacheKey
))
{
$sitemapData
=
$module
->
buildSitemap
(
true
);
}
Yii
::
$app
->
response
->
format
=
\yii\web\Response
::
FORMAT_RAW
;
$headers
=
Yii
::
$app
->
response
->
headers
;
$headers
->
add
(
'Content-Type'
,
'application/xml'
);
if
(
$module
->
enableGzip
)
{
$sitemapData
=
gzencode
(
$sitemapData
);
$headers
->
add
(
'Content-Encoding'
,
'gzip'
);
$headers
->
add
(
'Content-Length'
,
strlen
(
$sitemapData
));
}
return
$sitemapData
;
}
}
frontend/modules/sitemap/views/default/index.php
View file @
eb510db1
...
...
@@ -17,7 +17,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
<url>
<loc>
<?=
yii\helpers\Url
::
to
(
$url
[
'loc'
],
true
)
?>
</loc>
<?php
if
(
$langs
)
:
<?php
if
(
$l
inks
&&
$l
angs
)
:
foreach
(
$langs
as
$lang
)
:
?>
<xhtml:link
rel=
"alternate"
hreflang=
"
<?=
$lang
->
url
?>
"
href=
"
<?=
yii\helpers\Url
::
to
((
!
$lang
->
default
?
'/'
.
$lang
->
url
:
''
)
.
(
$url
[
'loc'
]
==
'/'
?
''
:
'/'
.
$url
[
'loc'
]),
true
)
?>
"
/>
<?php
endforeach
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment