Skip to content

Instantly share code, notes, and snippets.

@but1head
Created January 31, 2018 06:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save but1head/14cd3a47940233b30766910a3c43c3a4 to your computer and use it in GitHub Desktop.
Save but1head/14cd3a47940233b30766910a3c43c3a4 to your computer and use it in GitHub Desktop.
<?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