Commit fccb31d559c73a0c41683127f247a398c5f1239f
1 parent
8a41134e
sitemap controller not like noindex
Showing
1 changed file
with
16 additions
and
2 deletions
Show diff stats
console/controllers/SiteMapController.php
... | ... | @@ -27,6 +27,7 @@ class SiteMapController extends Controller |
27 | 27 | { |
28 | 28 | |
29 | 29 | private $urlList = ['http://www.rukzachok.com.ua/']; |
30 | + private $urlBlockedList = []; | |
30 | 31 | private $count = 1; |
31 | 32 | |
32 | 33 | public function getAddStatic() { |
... | ... | @@ -70,7 +71,14 @@ class SiteMapController extends Controller |
70 | 71 | |
71 | 72 | public function getSeoLinks() { |
72 | 73 | |
73 | - return Seo::find()->where(['not like', 'meta', 'noindex'])->all(); | |
74 | + return Seo::find()->all(); | |
75 | + | |
76 | + } | |
77 | + | |
78 | + public function getBlocked() { | |
79 | + | |
80 | + Seo::find()->where(['like', 'meta', 'noindex'])->all(); | |
81 | + | |
74 | 82 | |
75 | 83 | } |
76 | 84 | |
... | ... | @@ -101,7 +109,7 @@ class SiteMapController extends Controller |
101 | 109 | $reverse_url = preg_replace('/filters:([^=]+=[^=]+);([^=]+=[^=]+)/', 'filters:$2;$1', $url); |
102 | 110 | } |
103 | 111 | |
104 | - if(in_array($url, $this->urlList) || (isset($reverse_url) && in_array($reverse_url, $this->urlList))) { | |
112 | + if(in_array($url, $this->urlList) || (isset($reverse_url) && in_array($reverse_url, $this->urlList)) || in_array($url, $this->urlBlockedList)) { | |
105 | 113 | return false; |
106 | 114 | } else { |
107 | 115 | $this->urlList[] = $url; |
... | ... | @@ -144,6 +152,12 @@ class SiteMapController extends Controller |
144 | 152 | |
145 | 153 | $content = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; |
146 | 154 | |
155 | + //init $urlBlockedList | |
156 | + foreach ($this->getBlocked() as $link) { | |
157 | + $url = Yii::$app->urlManager->baseUrl.$link->url; | |
158 | + $this->urlBlockedList[] = $url; | |
159 | + } | |
160 | + | |
147 | 161 | //home page + home catalog |
148 | 162 | foreach ($this->getAddStatic() as $page) { |
149 | 163 | $this->createRow($page , 1,$content); | ... | ... |