Hi,
this might help someone who got problems with google sitemaps.
As I've seen there can arise two problems with "/catalog/view/theme/default/template/feed/google_sitemap.tpl"
1.) If you've have activated in "php.ini" the short_open_tag you'll get a php error. To solve this change the first line of the script to:
echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>';
?>
2.) For sure you'l get an error at web-webmaster moaning about bad time stamp. to solve this change the whole script to:
$datetime = new DateTime($result['date']);
echo $datetime->format('Y-m-d\TH:i:sP'); ?>
echo $datetime->format('Y-m-d\TH:i:sP');
?>
weekly
0.5
I hope this helps
Hermann
this might help someone who got problems with google sitemaps.
As I've seen there can arise two problems with "/catalog/view/theme/default/template/feed/google_sitemap.tpl"
1.) If you've have activated in "php.ini" the short_open_tag you'll get a php error. To solve this change the first line of the script to:
echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>';
?>
2.) For sure you'l get an error at web-webmaster moaning about bad time stamp. to solve this change the whole script to:
echo $datetime->format('Y-m-d\TH:i:sP'); ?>
?>
I hope this helps
Hermann
In SEO
Share this post:
Responses (7)
-
Accepted Answer
We had at Joomla about 10 years ago a discussion about short_tags.
Important is that here http://php.net/manual/en/ini.core.php#ini.short-open-tag
If you want to use PHP in combination with XML, you can disable this option in order to use inline. Otherwise, you can print it with PHP, for example: '; ?>.
The moment you use xml files (and that is what Joomla, Arastta, OC and nearly all other system I know using), short_tags should be avoided.
I for myself have never used short_tags and I am using php since 17 years.
Maybe I was wrong with the 'deprecated' because having in mind the troubles enabled short_tags can lead.
Nevertheless, this code changing wont worry nobody .. -
Accepted Answer
Good point Michael.
short_open_tag was used to enable the usage of a tag which is now enabled by default since PHP 5.4
While there are very hot discussions about the usage of short tags, I was not able to find any warning about depreciation. -
Accepted Answer
-
Accepted Answer
-
Accepted Answer
Here it is again:
<?php
echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<?php foreach ($results as $result) { ?>
<url>
<loc><?php echo $result['url']; ?></loc>
<?php if (isset($result['date'])) { ?>
<lastmod><?php
$datetime = new DateTime($result['date']);
echo $datetime->format('Y-m-d\TH:i:sP'); ?></lastmod>
<?php } else { ?>
<lastmod><?php $datetime = new DateTime(date('Y-m-d'));
echo $datetime->format('Y-m-d\TH:i:sP');
?></lastmod>
<?php } ?>
<changefreq>weekly</changefreq>
<?php if (isset($result['prior'])) { ?>
<priority><?php echo $result['prior']; ?></priority>
<?php } else { ?>
<priority>0.5</priority>
<?php } ?>
<?php if (isset($result['img'])) { ?>
<image:image>
<image:loc><?php echo $result['img']; ?></image:loc>
<image:caption><?php echo $result['name']; ?></image:caption>
<image:title><?php echo $result['name']; ?></image:title>
</image:image>
<?php } ?>
</url>
<?php } ?>
</urlset>
-
Accepted Answer
-
Accepted Answer
Your Reply
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »