{{indexmenu_n>30}} ====== Sitemap-XML (Google) ====== ===== Category link instead of article link ===== Using Category links instead of Article Links. Only one category link entry with the most recent Article Date is used. Setting in "CUSTMOM VAR": [true|false] [Category-Link | Article-link] **Update V1.1: 15.07.2010 KH** \\ - Small correction in row 102, if "mod_rewrite = 0" the URL was lost in the output. $_link = PHPWCMS_URL.'index.php?'.($cat_link)?$_CAT['acat_alias']:setGetArticleAid( $data ); // +KH replaced by $_link = PHPWCMS_URL.'index.php?'.(($cat_link)?$_CAT['acat_alias']:setGetArticleAid( $data )); // +KH \\ '.LF; echo ''.LF; echo ' '.LF.LF; //reads complete structure as array $struct = get_struct_data(); // fallback value when no article available $base = true; // now retrieve all articles $sql = "SELECT article_id, article_cid, DATE_FORMAT(article_tstamp, '%Y-%m-%d') AS article_tstamp, "; $sql .= "article_title, article_redirect, article_aliasid, article_alias "; $sql .= "FROM ".DB_PREPEND."phpwcms_article WHERE "; $sql .= "article_public=1 AND article_aktiv=1 AND article_deleted=0 AND article_nosearch!='1' AND "; $sql .= "article_nositemap=1 AND article_begin < NOW() AND article_end > NOW() "; $sql .= "ORDER BY article_tstamp DESC"; if($result = mysql_query($sql, $db)) { $temp_entry = array(); while($data = mysql_fetch_assoc($result)) { // first proof if this article is within an "public" structure section $_CAT = $struct[$data['article_cid']]; if($_CAT['acat_regonly'] || $_CAT['acat_nosearch']=='1' || !$_CAT['acat_nositemap']) { // no it is no public article - so jump to next entry continue; } // +KH: No double category link if cat_link is active // Only the most recent date is set // ---------------------------------------------- if ($cat_link) { if (!isset($temp_entry[$_CAT['acat_id']])) $temp_entry[$_CAT['acat_id']] = true; else continue; // +KH: one category link with the most recent date is set } // ---------------------------------------------- // now add article URL to Google sitemap if(empty($phpwcms['rewrite_url']) || empty($data['article_alias'])) { // $_link = PHPWCMS_URL.'index.php?'.setGetArticleAid( $data ); $_link = PHPWCMS_URL.'index.php?'.(($cat_link)?$_CAT['acat_alias']:setGetArticleAid( $data )); // +KH } else { // $_link = PHPWCMS_URL.rawurlencode($data['article_alias']).'.phtml'; $_link = PHPWCMS_URL.rawurlencode(($cat_link)?$_CAT['acat_alias']:$data['article_alias']).'.phtml'; // +KH } echo ' '.LF; echo ' '.$_link.''.LF; echo ' '.$data["article_tstamp"].''.LF; echo ' '.LF; // yes we have a minimum of 1 article link $base = false; } } echo LF.' '.LF; if(is_array($_addURL) && count($_addURL)) { foreach($_addURL as $value) { $_link = empty($value['url']) ? '' : trim($value['url']); if(empty($_link)) { continue; } $_lastmod = empty($value['date']) ? '' : trim($value['date']); if(empty($value['date'])) { $_lastmod = date('Y-m-d'); } echo ' '.LF; echo ' '.$_link.''.LF; echo ' '.$_lastmod.''.LF; echo ' '.LF; } } else { echo ' '.LF.LF; } if($base) { // just return the main URL echo ' '.LF; echo ' '.PHPWCMS_URL.''.LF; echo ' '.date('Y-m-d').''.LF; echo ' '.LF; } echo ''; ?> \\ ===== Change index.php?alias to alias.phtml ===== **Since r398 implemented in core :!:** Forum: [[http://forum.phpwcms.org/viewtopic.php?p=112317#p112317]] Rewriting sitemap output of ##/sitemap.php## for sitemap.xml file. (index.php?alias -> /alias.phtml) Normally the rewriting to alias.phtml is an htaccess funktion via apache. Patch for sitemap.php: (But only if you are using a standard .htaccess and rewrite to alias.phtml) === Insert between: === Begin:require_once (PHPWCMS_ROOT.'/include/inc_front/front.func.inc.php'); **Insert:** // enhanced by k.Heermann (flip-flop) for rewriting to alias.phtml // --------------------------------------------------------------- +kh 09/01/06 $my_rewrite = false; if ($phpwcms['rewrite_url'] >= 1 AND file_exists('.htaccess')) { $my_rewrite = true; } // ---------------------------------------------------------------- End: // start XML echo ''.LF; \\ and === Substitute: === $_link = PHPWCMS_URL.'index.php?'.setGetArticleAid( $data ); **with:** // ---------------------------------------- +kh 09/01/06 if ($my_rewrite) { $_link = PHPWCMS_URL.setGetArticleAid( $data ).'.phtml'; } else { $_link = PHPWCMS_URL.'index.php?'.setGetArticleAid( $data ); } // ---------------------------------------- \\ ===== Multidomain sitemap.php ===== Enhanced version for using a start-Id in tree against a domain. // Your strukture ID -> where would you like to start your sitemap? $my_start_id = 22; //default if no domain name is given // All Cat-IDs which have to be excluded permanently e.g. '4,7,34,9' $_DISABLE_ID = '4,7,34,9'; // Test // Add the respective START ID corresponding with your domain: remove comment slashes and enter them $_DOMAIN_ID = array( // 'domain1.de' => array( 'ID' => 1 ), // 'domain2.com' => array( 'ID' => 3 ), // 'domain3.ch' => array( 'ID' => 11 ), ); **Available for people those who are writing useful contributions, translations or video clips for the wiki.** // (As an alternative you could also make an donation).// \\