Sitemap plugin
- AuroraZero
- Posts: 3
- Joined: Mon Feb 24, 2020 4:50 am
Sitemap plugin
What has happened to sitemap plugin. It breaks everything when you enable it. I found an updated one, but it does the same now. I am not proficient enough to fix either of them yet. If some one has the time and can update it, that would be extremely useful, maybe just to me but others as well.
Re: Sitemap plugin
I was never able to get the sitemap plugin working myself, but then after a bit of searching, I came across Igor Kromin's blog, in which he made his own sitemap code, and it couldn't be simpler to use (seriously, the guy is a master at Flatpress). The code I'll share below also includes his updated version of the code, which allows the sitemap to also index static page links after the blog entries. You can see his linked blog entry for more details on that.
First off, make a file called "sitemap.php" in the root of your flatpress install (where index.php is), and fill it with the following code:
Simply save that, and in your browser, go to "YOUR-BLOG-URL.com/sitemap.php" and you'll have a fully generated sitemap.
Now, if you're using prettyurls, then the urs in the sitemap won't match what your blog url usually says... these links will still work, but you're using prettyurls for a reason, right?!
We can easily fix this by changing a single line of code. In your "sitemap.php" file, find the line that says:
And change it to:
Then, if you want to remove "?page=" from the URLs of your static pages in the sitemap, simply find the line that says:
And change it to:
That should fix everything!
As an added part to this post, if you don't want to include Static pages for whatever reason, simply change:
To:
And that should be it! According to the original blog, this code generates a "Google compatible sitemap", which is what I think we're all pretty much after.
You can obviously go on to modify the code as you wish, but this is a good start, I think.
First off, make a file called "sitemap.php" in the root of your flatpress install (where index.php is), and fill it with the following code:
Code: Select all
<?php
require_once('defaults.php');
require_once(INCLUDES_DIR.'includes.php');
if (function_exists('system_init')) {
system_init();
}
else {
plugin_loadall();
}
header('Content-Type: text/xml; charset=utf-8');
error_reporting(E_ALL);
echo("<?");
?>xml version="1.0" encoding="UTF-8"<?php echo("?>"); ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc><?=BLOG_BASEURL?></loc>
<lastmod><?=date("c");?></lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<?
$q = new FPDB_Query(array('start'=>0, 'count'=>-1, 'fullparse'=>true), null);
while($q->hasMore()) {
list($id, $e) = $q->getEntry();
$offset = $fp_config['locale']['timeoffset'];
if (isset($e['lastupdate'])) {
$lastmod = $e['lastupdate'] - (60 * 60 * $offset);
}
else {
$lastmod = $e['date'] - (60 * 60 * $offset);
}
$loc = BLOG_BASEURL . "index.php?x=entry:" . $id;
?>
<url>
<loc><?=$loc?></loc>
<lastmod><?=date("c", $lastmod);?></lastmod>
</url>
<?php
}
$ss = static_getlist();
foreach($ss as $k => $val) {
$s = static_parse($val);
$i = BLOG_BASEURL . '?page=' . $val;
$offset = $fp_config['locale']['timeoffset'];
$d = $s['date'] - (60 * 60 * $offset);
$d = date('c', $d);
echo('<url><loc>' . $i . '</loc><lastmod>' . $d . '</lastmod></url>');
}
?>
</urlset>
Now, if you're using prettyurls, then the urs in the sitemap won't match what your blog url usually says... these links will still work, but you're using prettyurls for a reason, right?!
We can easily fix this by changing a single line of code. In your "sitemap.php" file, find the line that says:
Code: Select all
$loc = BLOG_BASEURL . "index.php?x=entry:" . $id;
Code: Select all
$loc = get_permalink($id);
Code: Select all
$i = BLOG_BASEURL . '?page=' . $val;
Code: Select all
$i = BLOG_BASEURL . '' . $val;
As an added part to this post, if you don't want to include Static pages for whatever reason, simply change:
Code: Select all
<?php
}
$ss = static_getlist();
foreach($ss as $k => $val) {
$s = static_parse($val);
$i = BLOG_BASEURL . '?page=' . $val;
$offset = $fp_config['locale']['timeoffset'];
$d = $s['date'] - (60 * 60 * $offset);
$d = date('c', $d);
echo('<url><loc>' . $i . '</loc><lastmod>' . $d . '</lastmod></url>');
}
?>
</urlset>
Code: Select all
<?php
}
?>
</urlset>
You can obviously go on to modify the code as you wish, but this is a good start, I think.
- AuroraZero
- Posts: 3
- Joined: Mon Feb 24, 2020 4:50 am
Re: Sitemap plugin
I appreciate this, but I tried the code from the same site and it totally borked my blog. I will give this code a go and see what happens, maybe it will work this time. If this works you may want to submit it to the wiki, so everyone can use it.
Re: Sitemap plugin
Considering this doesn't touch ANY code from your blog, it's impossible for it to do such, so it would be something else that is messing up your site. What exactly is happening to your site, and what is the error message (if any) you're getting?AuroraZero wrote: โMon Mar 02, 2020 3:30 pm I appreciate this, but I tried the code from the same site and it totally borked my blog.
When it comes to this code, you literally just make a sitemap.php with it, and bam, it works. I can confirm it 100% works with a sitemap.php file I made minutes ago, and you can see that for yourself at: https://www.clockworkknight.com/flat/sitemap.phpI will give this code a go and see what happens, maybe it will work this time.
Sorry, but I don't really have time to be editing the wiki, as I have my own projects to deal with.If this works you may want to submit it to the wiki, so everyone can use it.
That said, the information is here and won't be going away any time soon, so feel free to add it to the wiki yourself, even if you just straight up copy and paste what I've written in my first response to you. Sky's the limit, etc!
- AuroraZero
- Posts: 3
- Joined: Mon Feb 24, 2020 4:50 am
Re: Sitemap plugin
I have reinstalled since then, and have not tried the code with it. It may have been an older version of this I tried, but none the less my site became completely inaccessible. Did not give an error code or anything just could not access it, and I was not the only one. All my monitoring went crazy telling me it was down, so I reinstalled.
Maybe today I will have a little time and try this out. I understand it does not do anything to the code of site. As I said before it may have been a different version, and maybe even a different author. my blog is mainly a venting area for me, and I just want Google/Bing/Yahoo etc.. to quit griping that there is no sitemap.
Maybe today I will have a little time and try this out. I understand it does not do anything to the code of site. As I said before it may have been a different version, and maybe even a different author. my blog is mainly a venting area for me, and I just want Google/Bing/Yahoo etc.. to quit griping that there is no sitemap.
Re: Sitemap plugin
Hi alltogether,
thanks for digging out that fine piece of Igor's code. I added a sitemap.php to the standard. Please feel free to get it here and test it: https://github.com/flatpressblog/flatpr ... itemap.php
Please let me know if that works correctly. It will later be part of the standard 1.2 distribution.
All the best,
Arvid
thanks for digging out that fine piece of Igor's code. I added a sitemap.php to the standard. Please feel free to get it here and test it: https://github.com/flatpressblog/flatpr ... itemap.php
Please let me know if that works correctly. It will later be part of the standard 1.2 distribution.
All the best,
Arvid
Project blogโโ Docsโโ Twitterโโ Mastodonโโ Forum RSS feedโโ Project blog RSS feedโโ Donate
FlatPress 1.3 "Andante" is released!
How to rework your themes and plugins for FlatPress 1.3 / Smarty 4
FlatPress 1.3 "Andante" is released!
How to rework your themes and plugins for FlatPress 1.3 / Smarty 4
Who is online
Users browsing this forum: No registered users and 42 guests