Welcome to Geeklog Monday, October 25 2021 @ 12:03 am EDT

Geeklog Forums

How does XMLSitemap work in retrospect?


Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
The wiki says XMLSitemap is based on PLG_itemSaved and PLG_itemDeleted. But it does have a way to detect existing items when upgrading to v1.6.

So please mention how it's done so plugins could do it too (e.g. imagine MG with countless of existing items).
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
On installation, it goes through all the existing posts using PLG_getItemInfo. The functionality of that API function was extended in 1.6.0 to make that possible.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
Is there an official way to make it run on another plugin?

Also, is there a way to automatically add a plugin to "XMLSitemap Main Settings"? And how does a plugin register itself in "Priority" and "Update frequency"?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
It's mostly automatic, actually. The XMLSitemap plugin can detect when another plugin is installed(*) and checks if that plugin supports the necessary API functions. If so, the plugin is added automatically. Frequency etc. are set to default values.

bye, Dirk

(*) assuming the other plugin uses the autoinstall
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
But how can you re-install a plugin without losing its whole database?

Are the necessary API functions PLH_itemSaved, PLG_itemDeleted and PLG_getItemInfo?
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
It seems the only way to do this for upgrades and/or for pre-v1.6 installations is by including this in the relevant function:
PHP Formatted Code

function plugin_upgrade_<plugin_name>()
...
    if (function_exists('plugin_pluginstatechange_xmlsitemap') && !in_array('<plugin_name>', $_XMLSMAP_CONF['types']))
       plugin_pluginstatechange_xmlsitemap('<plugin_name>', 'installed');
 
PHP Formatted Code

function plugin_install_<plugin_name>() / function plugin_install_now()
...
    if (function_exists('plugin_pluginstatechange_xmlsitemap'))
       plugin_pluginstatechange_xmlsitemap('<plugin_name>', 'installed');
 

It then sends a "*" (i.e. request for all IDs) to plugin_getiteminfo_<plugin_name>.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Go to Configuration > XMLSitemap > Contents of sitemap, add a new entry for your plugin. What's so complicated about this?

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
Because I'm talking as a plugin developer, not a plugin user.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
But since the user can add the plugin to the sitemap if they want there is no reason for the plugin developer to do that.
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
I doubt most users would appreciate that (let alone actually do that).
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Oh give us a break please ...

The scenario you're describing only affects plugins that already support the required functions. How many are there? The ones that are bundled with 1.6.0 and, I guess, your MultiFAQ plugin.

Once 1.6.0 is out and users install a new plugin that supports the new API functions, XMLSitemap will pick it up automatically.

So this only affects the unlikely scenario of having content in a plugin that already has the new functions and upgrading such a site to 1.6.0. I guess other than your own site, this won't affect anyone. And for you, there's still the option to add the plugin manually once.

Talk about blowing things out of proportion ...

Besides, you shouldn't try and access the internals of other plugins (as you posted above).

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
I'm not sure whether to take it as a compliment or not. You basically claim I'm the only plugin developer out there who will ever want to add v1.6 functions to an existing external plugin. It really doesn't look good if no one thinks MG, the forum, etc. have even the slightest chance to ever support v1.6 functions for sites that installed these plugins before v1.6.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
No, he's saying that once people upgrade to 1.6, they will add mg and forum to the xmlsitemap list manually. Then when mg and forum support the new functionality, there won't be anything for the plugin writer to do since the admin will have already taken care of it. On the other hand, if the admin does not manually add these plugins to the xmlsitemap list, then perhaps the admin doesn't want them on the site map and it would behoove the plugin author not to modify things behind the admin's back.
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
Does manual addition add existing items or only new ones (until a site upgrade/installing a new plugin)?
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 19/02/04
Posts: 818
It seems the answer is only new ones. In any case, I've released MultiFAQ v3.1.2 with sitemap support. When it decides which questions to include, it also takes in consideration the permissions of the questions' topics and whether their language is disabled in the FAQ.

It made me notice function STORY_getItemInfo is only called when creating/editing stories and not when editing/deleting topics. A loop should be called upon changing a topic's permissions/deleting the topic, to add/delete in the sitemap every story that belongs to that topic.
 Quote

All times are EDT. The time is now 12:03 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content