The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 861 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION CDATA IN SITEMAP.XML
#10
This generate_sitemap() will do what you want for the <loc> field.
The xml had to be changed to our SimpleXMLExtended to include the cdata function.

note that the i18n nav plugin uses its own function!

This will probably not work correctly though since the urls are already encoded, you probably have to entitydecode them in the cdata now.

PHP Code:
/**
 * Creates Sitemap
 *
 * Creates sitemap.xml in the site's root.
 */
function generate_sitemap() {

    if(
getDef('GSNOSITEMAP',true)) return;

    
// Variable settings
    
global $SITEURL;
    
$path GSDATAPAGESPATH;
    
    global 
$pagesArray;
    
getPagesXmlValues(false);
    
$pagesSorted subval_sort($pagesArray,'menuStatus');
    
    if (
count($pagesSorted) != 0)
    { 
        
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
        
$xml->addAttribute('xsi:schemaLocation''http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd''http://www.w3.org/2001/XMLSchema-instance');
        
$xml->addAttribute('xmlns''http://www.sitemaps.org/schemas/sitemap/0.9');
        
        foreach (
$pagesSorted as $page)
        {
            if (
$page['url'] != '404')
            {        
                if (
$page['private'] != 'Y')
                {
                    
// set <loc>
                    
$pageLoc find_url($page['url'], $page['parent']);
                    
                    
// set <lastmod>
                    
$tmpDate date("Y-m-d H:i:s"strtotime($page['pubDate']));
                    
$pageLastMod makeIso8601TimeStamp($tmpDate);
                    
                    
// set <changefreq>
                    
$pageChangeFreq 'weekly';
                    
                    
// set <priority>
                    
if ($page['menuStatus'] == 'Y') {
                        
$pagePriority '1.0';
                    } else {
                        
$pagePriority '0.5';
                    }
                    
                    
//add to sitemap
                    
$url_item $xml->addChild('url');
                    
                    
$item $url_item->addChild('loc');
                    
$item->addCData($pageLoc);
                    
                    
$url_item->addChild('lastmod'$pageLastMod);
                    
$url_item->addChild('changefreq'$pageChangeFreq);
                    
$url_item->addChild('priority'$pagePriority);
                }
            }
        }
        
        
//create xml file
        
$file GSROOTPATH .'sitemap.xml';
        
$xml exec_filter('sitemap',$xml);
        
XMLsave($xml$file);
        
exec_action('sitemap-aftersave');
    }
    
    if (!
defined('GSDONOTPING')) {
        if (
file_exists(GSROOTPATH .'sitemap.xml')){
            if( 
200 === ($status=pingGoogleSitemaps($SITEURL.'sitemap.xml')))    {
                
#sitemap successfully created & pinged
                
return true;
            } else {
                
error_log(i18n_r('SITEMAP_ERRORPING'));
                return 
i18n_r('SITEMAP_ERRORPING');
            }
        } else {
            
error_log(i18n_r('SITEMAP_ERROR'));
            return 
i18n_r('SITEMAP_ERROR');
        }
    } else {
        
#sitemap successfully created - did not ping
        
return true;
    }

NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply


Messages In This Thread
CDATA IN SITEMAP.XML - by Carrara - 2015-07-01, 11:16:23
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 11:38:03
RE: CDATA IN SITEMAP.XML - by Carrara - 2015-07-01, 11:57:52
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 12:02:40
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 12:04:23
RE: CDATA IN SITEMAP.XML - by Carrara - 2015-07-01, 12:08:50
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 12:10:44
RE: CDATA IN SITEMAP.XML - by Carrara - 2015-07-01, 12:14:09
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 22:47:09
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 23:04:14
RE: CDATA IN SITEMAP.XML - by shawn_a - 2015-07-01, 23:11:31
RE: CDATA IN SITEMAP.XML - by Carrara - 2015-07-02, 11:55:49
RE: CDATA IN SITEMAP.XML - by Carrara - 2015-07-02, 07:35:25



Users browsing this thread: 2 Guest(s)