-
-
Save but1head/14cd3a47940233b30766910a3c43c3a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = ""; | |
$resources = $modx->runSnippet('pdoResources', [ | |
'parents' => 0, | |
'limit' => 0, | |
'leftJoin' => '{ | |
"localizator" : { | |
"class" : "localizatorContent", | |
"alias" : "localizator", | |
"on" : "localizator.resource_id = modResource.id" | |
} | |
}', | |
'select' => '{ "localizator" : "modResource.*, localizator.*, modResource.id" }', | |
'where' => [ | |
'localizator.key' => $modx->localizator_key, | |
'localizator.active' => 1, | |
], | |
'return' => 'json', | |
]); | |
if($resources) { | |
$resources = json_decode($resources); | |
foreach($resources as $resource) { | |
$url = $modx->config['site_url'] . $resource->uri; | |
$changefreq = 'weekly'; | |
$priority = '0.5'; | |
// дата изменения | |
$lastmod = date('Y-m-d', $resource->editedon ?: $resource->createdon); | |
/* if($row['last_review_date']){ | |
$date = new DateTime($row['last_review_date']); | |
$lastmod = $date->format('Y-m-d'); | |
} */ | |
// пометка ежечастного обноавления, id категорий | |
if(in_array($resource->parent, [195, 2, 138, 196, 197, 198, 199, 24])) $changefreq = 'hourly'; | |
// приоретитет | |
if(in_array($resource->id, [2, 24, 138])) $priority = '1.0'; | |
$output .= " | |
<url> | |
<loc>{$url}</loc> | |
<lastmod>{$lastmod}</lastmod> | |
<changefreq>{$changefreq}</changefreq> | |
<priority>{$priority}</priority> | |
</url> | |
"; | |
} | |
} | |
return $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment