Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sitemap: useless actions sitemap-additem and save-sitemap
#1
I just wanted to enhance the I18N plugin to create correct sitemaps (with language in URL), but found out that the actions
  • sitemap-additem
  • save-sitemap
are useless, as the relevant variables are neither global nor passed to the action.
For 3.0 it would have been possible to add a admin menu item creating correct sitemaps but now with 3.1 and it's automatic generation of sitemaps this is not possible.

Edit: See also this topic regarding switching off sitemap generation/search engine pinging.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
No change in 3.2
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
yeah its a known issue, but i dont know that there is an actual issue created for it.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#4
Issue #363
Reply
#5
It seems this can be fixed by inserting this in function generate_sitemap()

Code:
global $xml, $page;

(admin/inc/template_functions.php)

...at least to fix action sitemap-additem. Those 2 variables are the ones that plugins try to use to add their own elements to the Sitemap.

I've tested this with News Manager (whose posts were added to the Sitemap with GS 3.0). I haven't tested with the I18N plugin, as it has its own patches for GS 3.1+

Any opinions, suggestions? Do you think it should be fixed other way, maybe new different hooks for Sitemap...?
Reply
#6
(2012-12-06, 02:47:49)Carlos Wrote: It seems this can be fixed by inserting this in function generate_sitemap()

Code:
global $xml, $page;

...

Any opinions, suggestions? Do you think it should be fixed other way, maybe new different hooks for Sitemap...?

To really solve issues like that I think that the action concept needs to be enhanced:
  • pass arguments to actions instead of relying on global variables (not needed here)
  • evaluate the return parameter

Then three actions (or rather two actions and one filter) can be used to allow for all eventualities:
Code:
function generate_sitemap() {
  # for special purposes, where the whole sitemap is generated by a plugin
  $done = exec_action('output-sitemap');
  if ($done) { exec_action('save-sitemap'); return; }
  ...
  foreach ($pagesSorted as $page) {
    $page = exec_filter('sitemap-additem', $page);
    # filter returns null to have page ignored
    # filter may adjust any fields, like private and add 'loc', ... (see below)
    if ($page) {
      # use $page['loc'], $page['lastmod'], $page['changefreq'], $page['priority'], if set
      # otherwise set them as now
      ...
    }
  }
  ...
  XMLsave($xml, $file);
  exec_action('save-sitemap');
}
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#7
Thanks for your suggestion.
Don't you think it might be better to use new hooks/filters (apart from your sitemap-output) instead of reusing sitemap-additem and sitemap-save? (and remove those two so that older plugins don't do strange things...)
Reply
#8
(2012-12-06, 03:45:02)Carlos Wrote: Don't you think it might be better to use new hooks/filters (apart from your sitemap-output) instead of reusing sitemap-additem and sitemap-save? (and remove those two so that older plugins don't do strange things...)

Yes, and harmonize the naming - start the name with the functionality/section: e.g. sitemap-output, sitemap-item, sitemap-save (as wrongly described in the wiki - instead of save-sitemap).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#9
What purpose does sitemap-item serve ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
(2012-12-06, 04:53:33)shawn_a Wrote: What purpose does sitemap-item serve ?
  • set the correct link (e.g. I18N plugin)
  • set another update date (e.g. plugins fixing pubDate issues or setting it, because other content that is included on the page has changed - blog/news plugins, Items Manager)
  • set frequency and priority (e.g. blog/news plugins)
  • do something else for each (or some) pages
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#11
I have not been following this nor do I use this functionality.
I apologize this this has been discussed.

I propose removing all sitemap hooks.
we can keep a notification hook for saved.

We use a single filter for sitemap modification.
Filters are made for modifying data.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
see https://github.com/GetSimpleCMS/GetSimpleCMS/issues/363
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
Since GS 3.3.0 there is a 'sitemap' filter.
Reply




Users browsing this thread: 1 Guest(s)