Commit 27ee5c4f authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Updated the API reference.

parent 68a6af0b
......@@ -206,13 +206,17 @@ function xmlsitemap_rebuild_form() {
$callbacks = $options = array();
foreach ($entities as $entity => $info) {
if (empty($info['xmlsitemap']['rebuild callback'])) {
// Only show entities which can be rebuilt.
// If the entity is missing a rebuild callback, skip.
continue;
}
if (!empty($info['object keys']['bundle']) && !xmlsitemap_get_link_type_enabled_bundles($entity)) {
// If the entity has bundles, but no enabled bundles, skip since
// rebuilding wouldn't get any links.
continue;
}
else {
// Build the list of callbacks and options for the form and batch
// processing.
$callbacks[$entity] = $info['xmlsitemap']['rebuild callback'];
$options[$entity] = $info['label'];
}
......
......@@ -15,66 +15,49 @@
/**
* Provide information on the type of links this module provides.
*
* @see hook_entity_info()
* @see hook_entity_info_alter()
*/
function hook_xmlsitemap_link_info() {
return array(
'mymodule' => array(
'purge' => TRUE, // A boolean if this link type can be purged during a rebuild.
'label' => 'My module',
'base table' => 'mymodule',
'object keys' => array(
// Primary ID key on {base table}
'id' => 'myid',
// Subtype key on {base table}
'bundle' => 'mysubtype',
),
'path callback' => 'mymodule_path',
'bundle label' => t('Subtype name'),
'bundles' => array(
'mysubtype1' => array(
'label' => t('My subtype 1'),
'admin' => array(
'real path' => 'admin/settings/mymodule/mysubtype1/edit',
'access arguments' => array('administer mymodule'),
),
'xmlsitemap' => array(
'status' => 1,
'priority' => 0.5,
),
),
),
'xmlsitemap' => array(
// Callback function to take an array of IDs and save them as sitemap
// links.
'process callback' => '',
// Callback function used in batch API for rebuilding all links.
'rebuild callback' => '',
// Callback function called from the XML sitemap settings page.
'settings callback' => '',
)
),
);
}
/**
* Retrieve a array of links to include in the sitemap.
*
* @return
* An array of link arrays with the following keys and values:
* - 'type' => The type of link (node, user, kitten, etc.).
* - 'id' => The ID of the link ($node->nid, $user->uid, etc.).
* - 'loc' => The un-aliased Drupal path to the item.
* - 'lastmod' => The UNIX timestmap of when the item was last modified.
* - 'changefreq' => The interval, in seconds, between the last set of changes.
* - 'priority' => An optional priority value between 0.0 and 1.0.
*/
function hook_xmlsitemap_links() {
$links = array();
$links[] = array(
'type' => 'mymodule',
'id' => 1,
'loc' => 'mymodule/menu/path',
'lastmod' => 346245692,
'changefreq' => 4600,
);
return $links;
}
/**
* Provide batch information for hook_xmlsitemap_links().
*
* It is highly recommended that if your module has a lot of items that could
* be sitemap links, that you implement this hook.
*
* All you need to do to implement this hook is add the required $context
* information.
*
* The optional current value will provide the offset parameter to
* hook_xmlsitemap_links() and should get records that are greater than this
* value. The default value is 0.
*
* The max (count) value will allow the batch to know when it is finished. This
* value is required.
*/
function hook_xmlsitemap_links_batch_info() {
return array(
'current' => 0,
// This value is used to start selecting items (WHERE id > current).
'max' => db_query("SELECT COUNT(id) FROM {mymodule}")->fetchField(),
// This should be the total number of items to process.
);
}
/**
* Alter the data of a sitemap link before the link is saved.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment