Jump to content

xml error 500 ?


iNoize
 Share

Recommended Posts

13 minutes ago, arjen said:

$config->debug = true

Can it help in this case? 500 is an internal server error (provided it is what we are talking about) if I'm not mistaken , so it is probably a server setup issue I suppose, in which case I would start troubleshooting by looking at the Apache log file.

However, I have never used this script so I might be easily mistaken.

  • Like 2
Link to comment
Share on other sites

It could be server issues, so looking at the logs is indeed logical. Also I've encountered 500 issues when the encoding isn't properly set. First thing I read: we need more info to help, therefore my question :)

  • Like 1
Link to comment
Share on other sites

Ok so i tried to fix it by myself now i have this warning. 

Maybe for the info: Its a multisite installation with one core but different DB's and labguages. 
This is currently my code in the  sitemap.xml  template. 

 

<?php namespace ProcessWire;
/**
 * ProcessWire Template to power a sitemap.xml 
 *
 * 1. Copy this file to /site/templates/sitemap-xml.php
 * 2. Add the new template from the admin.
 *    Under the "URLs" section, set it to NOT use trailing slashes.
 * 3. Create a new page at the root level, use your sitemap-xml template
 *    and name the page "sitemap.xml".
 *
 * Note: hidden pages (and their children) are excluded from the sitemap.
 * If you have hidden pages that you want to be included, you can do so 
 * by specifying the ID or path to them in an array sent to the
 * renderSiteMapXML() method at the bottom of this file. For instance:
 *
 * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); 
 * 
 *
 */

function renderSitemapPage(Page $page) {

	return 	"\n<url>" . 
		"\n\t<loc>" . $page->httpUrl . "</loc>" . 
		"\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . 
		"\n</url>";	
}

function renderSitemapChildren(Page $page) { 

	$out = '';
	$newParents = new PageArray(); 
	$children = $page->children; 
	
	foreach($children as $child) {
		$out .= renderSitemapPage($child);
		if($child->numChildren) $newParents->add($child); 
			else $this->wire('pages')->uncache($child); 
	}

	foreach($newParents as $newParent) {
		$out .= renderSitemapChildren($newParent); 
		$this->wire('pages')->uncache($newParent); 
	}

	return $out; 
}

function renderSitemapXML(array $paths = array()) {

	$out = 	'<?xml version="1.0" encoding="UTF-8"?>' . "\n" . 
		'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

	array_unshift($paths, '/'); // prepend homepage

	foreach($paths as $path) {
		$page = $this->wire('pages')->get($path); 
		if(!$page->id) continue; 
		$out .= renderSitemapPage($page);
		if($page->numChildren) $out .= renderSitemapChildren($page);
	}

	$out .= "\n</urlset>";

	return $out; 
}


if ($pages->get("1042")->sitemaps != " ") {
    $ausgabe =  renderSitemapXML(array(
        
  //  $ps = $pages->get("1042")->sitemaps;
  // foreach ($ps as $p) {
  // 	echo "$p->path";
  // }
   // 	'/hidden/page/'


    	));
}else{
	$ausgabe =  renderSitemapXML();
}

// echo renderSitemapXML();
// Example: echo renderSitemapXML(array('/hidden/page/')); 



header("Content-Type: text/xml");
echo $ausgabe;

 

Screenshot_2.jpg

Link to comment
Share on other sites

  • 1 month later...

So there are happens strange things. 

I have one core with different languages on pw 3+ e.g.  

de.mydomain.com 
en.mydomain.com 
.....

now i have taken the original code from ryan. Searching for one month for the error. 
The only thing i had to do is to "disable automatic prepand of _init.php" in the template settings :) 

awww maybe its a good advice for somebody. but peaople thanks for your help 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...