Jump to content

CMS page that I dont want to appear in the sitemap (possible?)


Recommended Posts

Hi everyone,

 

I have a CMS page that I dont want to appear in the site map under "Pages", is there a way to do this other than manually setting up the pages part of the site map content and just not having the page in question in there?

 

Thanks in advance.

Link to comment
Share on other sites

Thanks for the reply, I only want to remove the one CMS link that I dont want to appear, would editing the xml or gsitemap.php do this.

 

Im not worried about google or other search engines finding it, I just dont want it to be there when people view the sitemap directly on the website.

 

Hope that better explains what I mean.

Link to comment
Share on other sites

Hi sshare,

You can remove an individual link from your theme's sitemap.tpl file.

 

I hope this helps.

 

-Mike

 

Thanks Mike, I would but its a CMS page that I dont want in there.

 

The code is as follows:

 

 

<div class="categTree">

<h3>{l s='Pages'}</h3>

<div class="tree_top"><a href="{$categoriescmsTree.link}">{$categoriescmsTree.name|escape:'htmlall':'UTF-8'}</a></div>

<ul class="tree">

{if isset($categoriescmsTree.children)}

{foreach from=$categoriescmsTree.children item=child name=sitemapCmsTree}

{if (isset($child.children) && $child.children|@count > 0) || $child.cms|@count > 0}

{include file="$tpl_dir./category-cms-tree-branch.tpl" node=$child}

{/if}

{/foreach}

{/if}

{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}

{if $display_store}<li><a href="{$link->getPageLink('stores.php')}" title="{l s='Our stores'}">{l s='Our stores'}</a></li>{/if}

<li class="last"><a href="{$link->getPageLink('contact-form.php', true)}">{l s='Contact'}</a></li>

</ul>

</div>

 

So is the only way to remove that part of code and replace it with more or less the same just with each link added manualy (and thus ommiting the one I dont want)????

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}

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...
  • 1 month later...

Hello everyone :)

 

I have a similar request for some categorys.

 

I have some groupr restricted categorys and product at my shop, non visible to registered users.

 

Google asked me to block them in my robots.txt and I did it but now Google told me to remove them from sitemap too.

 

How can I achieve that ?

 

Is there a sitemap.tpl modification I can do to exclude some categorys and the products behond them ?

 

By the way, I tried lain code to remove cms page, that doesn't change anything apparently.

 

Thanks a lot in advance.

Edited by KevinNash (see edit history)
Link to comment
Share on other sites

Like I wrote there is hundreds of line to remove, I can't do that each time and found those pages manually, that's really too much ;)

 

I have 15 categories concerned, on 102 total, reserved to a special group of customers.

 

So I must avoid those categorys and products to generate.

 

The module should do that and not add restricted categories.

 

Isnn't there a piece of code to add to gsitemap.php to only generate for categories and products who are available for group 1 visitor ?

Link to comment
Share on other sites

edit the gsitemap.php of the gsitemap module, find this function

 

private function _getCategoryLink(&$link_sitemap, $lang, &$index, &$i, $id_category = 0)
{
$link = new Link();
if (method_exists('ShopUrl', 'resetMainDomainCache'))
ShopUrl::resetMainDomainCache();


$categories_id = Db::getInstance()->ExecuteS(
'SELECT c.id_category FROM `'._DB_PREFIX_.'category` c
INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON c.`id_category` = cs.`id_category`
WHERE c.`id_category` >= '.intval($id_category).' AND c.`active` = 1 AND c.`id_category` != 1 AND c.id_parent > 0 AND c.`id_category` > 0 AND cs.`id_shop` = '.(int)$this->context->shop->id.' ORDER BY c.`id_category` ASC'
);
 
and replace to
 
private function _getCategoryLink(&$link_sitemap, $lang, &$index, &$i, $id_category = 0)
{
$link = new Link();
if (method_exists('ShopUrl', 'resetMainDomainCache'))
ShopUrl::resetMainDomainCache();


$categories_id = Db::getInstance()->ExecuteS(
'SELECT c.id_category FROM `'._DB_PREFIX_.'category` c
INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON c.`id_category` = cs.`id_category`
WHERE c.`id_category` NOT IN (your ids that dont want to show) AND c.`active` = 1 AND c.`id_category` != 1 AND c.id_parent > 0 AND c.`id_category` > 0 AND cs.`id_shop` = '.(int)$this->context->shop->id.' ORDER BY c.`id_category` ASC'
);
Link to comment
Share on other sites

Hi :)

 

Thank you very much shacker, that works  like a charm :)

 

Using your code, I also did that to avoid the products in those categories to be in the sitemap, I modified :

	$products_id = Db::getInstance()->ExecuteS('SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product WHERE p.`active` = 1 AND p.`id_product` > '.(int)$id_product.(($this->tableColumnExists(_DB_PREFIX_.'product_lang', 'id_shop')) ? ' AND pl.`id_shop` = '.(int)$this->context->shop->id : '').' AND pl.`id_lang` = '.(int)$lang['id_lang'].' ORDER BY `id_product` ASC');

by :

		$products_id = Db::getInstance()->ExecuteS('SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product WHERE `id_category_default` NOT IN (categories ID I don't want to show) AND p.`active` = 1 AND p.`id_product` > '.(int)$id_product.(($this->tableColumnExists(_DB_PREFIX_.'product_lang', 'id_shop')) ? ' AND pl.`id_shop` = '.(int)$this->context->shop->id : '').' AND pl.`id_lang` = '.(int)$lang['id_lang'].' ORDER BY `id_product` ASC');
Edited by KevinNash (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...