[RFE] sitemap generator plugin: remove non-public posts
Posted: Sun Jul 20, 2008 7:34 pm
The sitemap generator plugin (currently v0.41) exports links to all blog entries. However sometimes it may be preferable to protect some entries and make them accessible to members only, or expire them altogether (eg. with the "Hide/delete entries for non-registered users after a specific timespan"-plugin).
The sitemap generator does not take this into account and will happily export all non-draft entries. Since it usually makes no sense that non-public entries show up in search engine results, (and sometimes you may not want to have others see the title of your blog postings), I hereby propose to remove these entries from the exported sitemap.
One way to achieve this is to change the SQL query in /plugins/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php:
could be replaced by:
Note: This code has only been tested in my current setup. It is based on the assumption that the entryproperties table always exists, and the value ep_access/public is always present for non-restricted entries.
The sitemap generator does not take this into account and will happily export all non-draft entries. Since it usually makes no sense that non-public entries show up in search engine results, (and sometimes you may not want to have others see the title of your blog postings), I hereby propose to remove these entries from the exported sitemap.
One way to achieve this is to change the SQL query in /plugins/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php:
Code: Select all
function add_entries(&$sitemap_xml) {
(..)
$entries = serendipity_db_query(
'SELECT
entries.id AS id,
entries.title AS title,
'.$sqlnullfunction.'(entries.last_modified,0) AS timestamp_1,
'.$sqlnullfunction.'(MAX(comments.timestamp),0) AS timestamp_2
FROM '.$serendipity['dbPrefix'].'entries entries
LEFT JOIN '.$serendipity['dbPrefix'].'comments comments
ON entries.id = comments.entry_id
WHERE entries.isdraft = \'false\'
GROUP BY entries.id, entries.title, entries.last_modified
ORDER BY entries.id',
false, 'assoc');
Code: Select all
$entries = serendipity_db_query(
'SELECT
entries.id AS id,
entries.title AS title,
'.$sqlnullfunction.'(entries.last_modified,0) AS timestamp_1,
'.$sqlnullfunction.'(MAX(comments.timestamp),0) AS timestamp_2
FROM '.$serendipity['dbPrefix'].'entries entries
LEFT JOIN '.$serendipity['dbPrefix'].'comments comments
ON entries.id = comments.entry_id
LEFT JOIN '.$serendipity['dbPrefix'].'entryproperties ep
ON entries.id = ep.entryid
AND ep.property = "ep_access"
WHERE entries.isdraft = \'false\'
AND ep.value = "public"
GROUP BY entries.id, entries.title, entries.last_modified
ORDER BY entries.id',
false, 'assoc');