-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.php
77 lines (59 loc) · 1.92 KB
/
sitemap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
// Composer
require __DIR__ . '/vendor/autoload.php';
use GoodGin\GoodGin;
$GoodGin = new GoodGin();
header("Content-type: text/xml; charset=UTF-8");
print '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
print '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Главная страница
$url = $GoodGin->Config->root_url;
$lastmod = date("Y-m-d");
print "\t<url>" . "\n";
print "\t\t<loc>$url</loc>" . "\n";
print "\t\t<lastmod>$lastmod</lastmod>" . "\n";
print "\t</url>" . "\n";
// Страницы
/*foreach($GoodGin->Pages->getPages() as $p) {
if($p->visible && $p->menu_id == 1) {
$url = $GoodGin->Config->root_url.'/'.esc($p->url);
print "\t<url>"."\n";
print "\t\t<loc>$url</loc>"."\n";
print "\t</url>"."\n";
}
}*/
// Блог
foreach ($GoodGin->Blog->getPosts(array('visible' => 1)) as $p) {
$url = $GoodGin->Config->root_url . '/blog/' . esc($p->url);
print "\t<url>" . "\n";
print "\t\t<loc>$url</loc>" . "\n";
print "\t</url>" . "\n";
}
// Категории
foreach ($GoodGin->ProductsCategories->get_categories() as $c) {
if ($c->visible) {
$url = $GoodGin->Config->root_url . '/' . esc($c->url);
print "\t<url>" . "\n";
print "\t\t<loc>$url</loc>" . "\n";
print "\t</url>" . "\n";
}
}
// Бренды
/*foreach($GoodGin->ProductsBrands->get_brands() as $b) {
$url = $GoodGin->Config->root_url.'/brands/'.esc($b->url);
print "\t<url>"."\n";
print "\t\t<loc>$url</loc>"."\n";
print "\t</url>"."\n";
}*/
// Товары
foreach ($GoodGin->Products->get_products(array("visible" => 1)) as $product) {
$product_url = $GoodGin->Config->root_url . '/tovar-' . esc($product->url);
print "\t<url>" . "\n";
print "\t\t<loc>$product_url</loc>" . "\n";
print "\t</url>" . "\n";
}
print '</urlset>' . "\n";
function esc($s)
{
return (htmlspecialchars($s, ENT_QUOTES, 'UTF-8'));
}