Zenphoto Sitemap plugin

Hi

I have been coding a bit on a Zenphoto plugin the last couple of days, it is a sitemap generator which can be used with the larger search engines (Google, Live Search, etc.) and it's compatible with the sitemaps.org specifications.

It's really simple to install, just copy the file into the zp-core/plugins directory, activate the plugin through the administration interface and then point the search engines at [your Zenphoto folder]/?sitemap, and it will take care of the rest.

Link for download and (a little) more info is on my homepage.

Note: I am aware that there is an existing Google sitemap generator already, which is mentioned on the hacks page. But I haven't been able to access the site linked to recently, and now that I have seen the code it honestly isn't that pretty made.

By the way... Shouldn't there be a plugins section here on the forums, in order to keep them a bit separated from the Zenphoto core?
«1

Comments

  • Plugin has been added to the topic list.
  • Just replaced the sitemap hack with this... works like a charm, and loads much quicker!

    How can we get this into the mainstream distro? :)
  • How this would happen depends on the wishes of the author. We can place a link or a download on the plugins page http://www.zenphoto.org/2008/06/zenphoto-plugins/.
  • Feel free to include it in the Zenphoto download package, or on the plugins page if you wish to. I would be thrilled if people would use it.
  • Sitemap has been added to the plugins list.
  • Any chance to include it in the download package moving forward?
  • Certainly, but since the developers will probably not be supporting it it might be more convenient for you to keep the download on your server. If that link will be constant we can provide it.
  • Thanks very much for this plugin! I installed it yesterday and submitted in google webmaster tools, it was crawled right away, and it's already leading to additional traffic - I'm getting top 3 in google for many search terms now for the albums, where my blog was hanging around page 2 for the same terms.

    One warning that I have in google is the following, FYI:
    For ?sitemap=root
    All the URLs in your Sitemap have the same priority.
    All the URLs in your Sitemap are set to the same priority (not the default priority). Priority indicates the importance of a particular URL relative to other URLs on your site, and doesn't impact your site's performance in search results. If all URLs have the same priority, Google can't tell which are more important.
  • I'm glad that you find the plugin useful and that it's helping you out :)

    Regarding that error, I have had another report from another user experiencing the same warning message. I don't think it has any effect, but the warning could probably be avoided by removing/commenting out line 64 of the plugin (`echo "1.0\n";`).
    I don't understand why I don't get the warning message though...
  • Tenzer: Thanks for taking time to write the plugin. I tried to see how the sitemap looks like in your site. I tried accessing http://gallery.tenzer.dk/?sitemap. It didn't produce XML sitemap. It created something like:

    http://gallery.tenzer.dk/?sitemap=root http://gallery.tenzer.dk/?sitemap=7 http://gallery.tenzer.dk/?sitemap=3 http://gallery.tenzer.dk/?sitemap=4 http://gallery.tenzer.dk/?sitemap=6 http://gallery.tenzer.dk/?sitemap=5 http://gallery.tenzer.dk/?sitemap=8 http://gallery.tenzer.dk/?sitemap=9

    Reg. priority: Only the top URL should be 1.0; album URLs can be 0.5; and all pictures should be 0.5 or 0.4;

    In your program, there is a common code to set priority for all URLs. If it's set based on type of the page (front page, album, picture, etc), that would be nice.

    Also, there is no frequency mentioned. SEs will love to see the frequency so that they know when to come back.

    I haven't installed your plugin yet. I want to change the priority parm before installing it.
  • Hi all

    I have updated the plugin with two minor fixes. You can read the detailed information at my homepage: http://tenzer.dk/zenphoto-sitemap-101

    jollywood, a sitemap was generated when you tried it out on my gallery, but your browser was simply interpreting the page as normal HTML, which means that it only showed the links. If you chose "View source" you would see the correct XML file.
    One of the changes in the new version is that the correct XML content type header is sent out, which informs your browser that it is receiving an XML file.

    The plugin doesn't specify any priorities any longer, since it didn't work out correctly before. In order for priorities to work correctly, all the URLs has to be in the same XML file, since the priorities are only compared with other URLs in the same XML file.
    Since that would be a larger piece of work that would need to be put into that, I just skipped out the priority part for now. It may be the next thing to do for the plugin.

    It's hard for me to specify the change frequency, as that purely depends on the activity in the gallery. Some logic to calculate how often new pictures are added, and how often new comments are posted would probably have to made then, which makes the plugin much larger than what I aimed it to be. I just wanted to have it as a file that is put into the Zenphoto plugin folder, and just works from there.
    The other approach to this would be that the administrator of the gallery simply specified the change frequency for each type of page (root, gallery, picture), and then some kind of interface would have to be made for this in the administration interface, but that is probably easier than coding the above described logic into the plugin.
  • The plugin has been updated again, in order to solve an issue when having folder or image paths with non-alphanumeric or international characters. You can find more information about it here:
    http://tenzer.dk/zenphoto-sitemap-102
  • After a long wait, I've gotten around to updating this plugin again, this time with a large rewrite, hence the new version number 2.0.0: http://tenzer.dk/zenphoto-sitemap-2-0-0

    This version does not really bring any new features, but instead gives performance improvements, and lowers the amount of database and HTTP queries needed from the search engines.

    I do have a few ideas for new features, which can be found on the issue tracker for the plugins GitHub page: http://github.com/Tenzer/zenphoto-sitemap/issues

    Let me know if you experience any issues with it, or if you have any feature requests!
  • Thank you for the plugin!

    I'd like to ask if it wouldn't be much trouble to provide an option to choose whether sitemap is to be created in gzipped form (sitemap.xml.gz) or not (sitemap.xml).

    Thank you
  • You're welcome :)

    I generally tried to make the plugin as easy to use as possible, by not requiring write permissions anywhere on the file system or any mod_rewrite rules and such, but I guess some checking could be made to see if a certain path is writable, and in that case generate a static sitemap. The difficult part would then be when to update the sitemap, but I'll have to look further into that.
  • acrylian Administrator, Developer
    @Tenzer: YOu might want to look at the static_html_cache plugin about updating static files (there are similar functions for the rss feeds, too).
  • Right, thank you for the hint acrylian. Otherwise I was thinking about storing a serialized array with all the current URLs in the database, and then update that once in a while. That would limit the amount of database queries significantly. But static files are most certainly more efficient :)
  • acrylian Administrator, Developer
    @Tenzer: In case you are interessted I have a little extended your sitemap plugin to cover Zenpage items as well. I also added caching within the standard html_cache folder. It runs on my demo site: http://zenphoto.maltem.de/?sitemap and download for now is here: http://zenphoto.maltem.de/uploaded/zenphoto-sitemap-extended.zip.
    Only thing missing is a admin overview button to clear the cache manually right now.
  • @acrylian: I've only had a short look at the code, and it looks interesting. I have to get a bit closer look at it, and test it out. I'll include it in the next release if everything works out fine, thank you :)
  • acrylian Administrator, Developer
    Alright...;-) The code for the button on admin overview is already there (commented out currently) but I could not get it to display on that page and currently don't know why that is so. Well, even developers missed something sometimes..;-)

    Btw, you/we could think about changing the plugin to use the object model framework later.
  • acrylian Administrator, Developer
    @tenzer: I am working on some more changes. I just noticed that I completly overlooked that it had a password breach (subalbums inherit from parents!). Sadly this required to split the plugin into two files: The plugin file and a sidemap.php file that works like the rss files. Will shortly post it for you to look at.
  • @acrylian Hmm, I haven't had a use for Zenpage yet, and hence I haven't played with it, so I'm not really sure what that means? Does the plugin breach the security of Zenphoto/Zenpage?

    I would really like to keep the plugin in one file in order to keep it simple to use. Simply drop it into the correct folder, activate the plugin and it should work. Why would there be a need for two files?
  • acrylian Administrator, Developer
    No, as written the password breach is for the albums. It is not enough to check for `password = ''` in a query as it will be empty for an subalbum whose parent is protected. But the subalbum in Zenphoto inherits the protection from the parent, thus an extra check is needed.

    The split into two files is necessary because somehow one internal function for this check does not work with the single file solution as it is not available and caused a fatal error.

    Of course if you don't use album passwords/album user assignments you don't need that but we want to have a general plugin, don't we?

    The usage is still very easy, drop the zenphoto-sitemap.php plugin into the `plugins` folder and then drop the sitemap.php file into the root. Done. Not really that complicated. If the plugin is disabled sitemap.php returns a 404 not found.
  • Okay, I get you now. Thank you for clarifying. I don't think the check would be that hard to do inside the plugin. It's probably a matter of first getting all 'root level' albums without passwords, then get their sub-albums without passwords, and so on. It will require a SQL query for each level of albums there is, but I don't think that is that bad.
    If there is already functions inside Zenphoto to do this check, then it would of course be better to use those.
  • acrylian Administrator, Developer
    Well, those function inside Zenphoto are the problem. You can see within the `image_album_statistics` plugin how this check should be done using `checkAlbumPassword()`. But somehow the `zp_loggedin()` function that is used within that causes said fatal error.

    I am actually wondering about that. I will have to consult sbillard on that next week.
  • acrylian Administrator, Developer
    I have uploaded my changes: http://zenphoto.maltem.de/uploaded/zenphoto-sitemap-extended2.zip
    Now there is also support for the <lastmod> and <changefreq> (the latter manually only). Also I cleaned up the code to use some function you did manually originally although we have functions for it and additonally there is now finally a "sitemap clear button" on the admin overview page. Because of the strangely not defined `zp_loggedin()` function anyone with overview rights can clear the cache.

    Please take a look if you have the time! It's also running on that demo site (called as said via /sitemap.php).
  • acrylian Administrator, Developer
    @Tenzer: I wanted to let you know that I have decided to make my sitemap plugin extension an official plugin. It is named "zenphoto-sizemap-extended" so it is not confused with yours (of course it is noted that it's based on your plugin). It's in tonight's nightly.
  • Hello,

    I have been using the site map plugin 2.0 with Zenphoto version 1.2.8 and easily installed it by placing the sitemap.php file in my plugins folder.

    I would like to try your new zenphoto-sitemap-extended. I downloaded the nightly (4-5-2010) as suggested and put that sitemap.php file in the plugins folder (also enabled sitemap in admin), but when I tried to access my site it returned errors. Also in the admin plugins "sitemap" simply shows up as "sitemap" it isn't bold followed by a version number like the other plugins. Do I need other updated files besides the sitemap.php?

    Thank-you
  • acrylian Administrator, Developer
    Yes, the new plugin consists of two files
    sitemap.php -> root of Zenphoto were rss.php is for example. This is the actual sitemap file that is called via `/sitemap.php` and generates it.
    sitemap-extended.php -> put into `zp-core/zp-extensions` (since it is offficial). These is the actual plugin that provides the functions for sitemap generation.

    As mentioned above the split was necessary because of an internal check for album password protection that otherwise does not work.

    Note it has only been tested with the nightly and for Zenpage support it requires the nightly because of a change. It is never recommended to mix files from releases.
  • Thank-you acrylian. My sitemap is generated when I use myurl/sitemap.php. So then I submit myurl/sitemap.php to the search engines instead of myurl/?sitemap. ?
Sign In or Register to comment.