Jump to content

Exclude page from sitemap (sitemap.php)


Recommended Posts

Hi There,

 

i have a problem, i want to exclude some CMS page from sitemap.php

for example : mysite.com/sitemap.php

 

Information

- Contact

- ...

- ...

- CMS Page 1

- CMS Page 2

- CMS Page 3 (i want to hide this)

- CMS Page 4

- CMS Page 5 (i want to hide this too)..

 

Can anybody help me to hide those pages, can i blocked by it's CMS ID? and how to do this?

 

thanks in advance

Link to comment
Share on other sites

in your gsitemap.php you will see the cms link build. You can modify either the db read or the foreach cms to skip the cms id you do not want your sitemap built for.

 

  if (Configuration::get('GSITEMAP_ALL_CMS') || !Module::isInstalled('blockcms'))
$sql_cms = '
SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').
' FROM '._DB_PREFIX_.'cms_lang cl
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
WHERE l.`active` = 1
ORDER BY cl.id_cms, cl.id_lang ASC';
  else if (Module::isInstalled('blockcms'))
$sql_cms = '
SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms').
' FROM '._DB_PREFIX_.'cms_block_page b
LEFT JOIN '._DB_PREFIX_.'cms_lang cl ON (b.id_cms = cl.id_cms)
LEFT JOIN '._DB_PREFIX_.'lang l ON (cl.id_lang = l.id_lang)
WHERE l.`active` = 1
ORDER BY cl.id_cms, cl.id_lang ASC';

  $cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms);
  foreach($cmss as $cms)
  {
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $link->getCMSLink((int)$cms['id_cms']);
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
  }

Link to comment
Share on other sites

  • 1 year later...

Hi, I found this thread in google trying to hide/exclude some CMS pages from prestashop in-page sitemap (not sitemap.xml)

If somebody reach this thread as I did, here is the solution in PS 1.4.5.1

in yourtheme/sitemap.tpl change

{foreach from=$categoriescmsTree.cms item=cms name=cmsTree}
<li><a href="{$cms.link|escape:'htmlall':'UTF-8'}" title="{$cms.meta_title|escape:'htmlall':'UTF-8'}">{$cms.meta_title|escape:'htmlall':'UTF-8'}</a></li>
{/foreach}

 

to

{foreach from=$categoriescmsTree.cms item=cms name=cmsTree}
{if $cms.id_cms==1}
{else}
<li><a href="{$cms.link|escape:'htmlall':'UTF-8'}" title="{$cms.meta_title|escape:'htmlall':'UTF-8'}">{$cms.meta_title|escape:'htmlall':'UTF-8'}</a></li>
{/if}
{/foreach}

where $cms.id_cms==1 is the CMS page´s ID you want to exclude

 

for example, to exclude CMS 1,2 and 3 it would be

{if $cms.id_cms==1 || $cms.id_cms==2 || $cms.id_cms==3}

Link to comment
Share on other sites

×
×
  • Create New...