PDA

View Full Version : site map plugin



Moosa Al shidhani
April 19, 2016, 05:13 PM
I noticed that categories in my auto websites are showing in the sitemap.xml which is automatically generated by the sitemap plugin, although I have set my website to hide empty categories from showing in home page.

I suggest an update to the plugin to allow users to select whether or not they want to hide empty categories from showing into sitemap.xml file.

Currently sitemap.xml is showing all categories and ultimately it will be indexed by google which does gives fake results to website visitors.

Moosa Al shidhani
April 21, 2016, 01:38 PM
Waiting for a reply please

Viktor
April 22, 2016, 09:38 AM
Hello Moosa,

You can try to do it yourself through ftp.
Open file: ftp://plugins>>sitemap>>rlSitemap.class.php

find method: getCategories and replace it to:



public function getCategories( $first = false )
{
global $rlHook, $config;

$sql = "SELECT SQL_CALC_FOUND_ROWS `T1`.`ID`, `T1`.`Path`, `T1`.`Parent_ID`, `T1`.`Status` , `T1`.`Modified`, `T1`.`Type`, `T1`.`Count`, ";
$sql .= "IF(`T2`.`Cat_hide_empty` = '1' AND `T1`.`Count` = '0', 1, 0) AS `Hide_cat` ";
$sql .= "FROM `" . RL_DBPREFIX . "categories` AS `T1` ";
$sql .= "LEFT JOIN `" . RL_DBPREFIX . "listing_types` AS `T2` ON `T1`.`Type` = `T2`.`Key` ";
$sql .= "WHERE `T1`.`Status` = 'active' ";

if ( $this -> languages_count > 1 )
{
$lenght = ceil( $this -> limit_urls / $this -> languages_count );

if ( $this -> start > 0 )
{
$start = ceil( $this -> start / $this -> languages_count );
}
else
{
$start = $this -> start;
}
}
else
{
$lenght = $this -> limit_urls;
$start = $this -> start;
}

$sql .= "LIMIT {$start},{$lenght}";

$GLOBALS['rlHook'] -> load('sitemapGetCategoriesBeforeGetAll');

$categories = $this -> getAll( $sql );

if ( $first )
{
$calc = $this -> getRow( "SELECT FOUND_ROWS() AS `calc`" );
$calc['calc'] = $this -> languages_count * $calc['calc'];
$this -> total += (int)$calc['calc'];
$this -> total_categories = (int)$calc['calc'];
}

$this -> languages_count > 1 ? $lang = '[lang]' .'/' : $lang = '';

if (!defined('SEO_BASE')) {
define('SEO_BASE', RL_URL_HOME.$lang);
}

foreach( $categories as $key => $val )
{
if($val['Hide_cat'] == 1) {
unset($categories[$key]);
continue;
}
if (method_exists($this, 'url')) {
$categories[$key]['url'] = $this->getCategoryUrl($val['ID'], $lang);
if (version_compare($GLOBALS['config']['rl_version'], '4.4.0') >= 0 && version_compare($GLOBALS['config']['rl_version'], '4.5.0') < 0) {
$this->addLangTemplate($listings[$key]['url'], $lang);
}
} else {
$categories[$key]['url'] = $this->base_path . $lang . ($GLOBALS['config']['mod_rewrite'] ? $this->pages['lt_'.$val['Type']] .'/'. $val['Path'] . '.html' : '?page=' . $this->pages['lt_'.$val['Type']] . '&amp;category=' . $val['ID']);
}
}
return $categories;
}

save and check sitemap again.

Pete Young
March 11, 2017, 04:21 AM
Does this work for 4.5.2 ? please

Curtis
March 14, 2017, 09:02 AM
Hi Pete,

You can try to add "return false;" in top of method.

http://forum.flynax.com/attachment.php?attachmentid=2245&stc=1

Pete Young
March 14, 2017, 09:05 AM
Thanks Curtis, I found an easy way to do this without any coding required, just go in and set any hidden unused categories to inactive and problem fixed.