Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
In the hook_query_xmlsitemap_generate_alter example there are references to the deprecated db_and and db_or functions. These should be replaced with the andConditionGroup and orConditionGroup functions.
/**
* Alter the query selecting data from {xmlsitemap} during sitemap generation.
*
* @param $query
* A Query object describing the composite parts of a SQL query.
*
* @see hook_query_TAG_alter()
*/
function hook_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
$sitemap = $query->getMetaData('sitemap');
if (!empty($sitemap->context['vocabulary'])) {
$node_condition = db_and();
$node_condition->condition('type', 'taxonomy_term');
$node_condition->condition('subtype', $sitemap->context['vocabulary']);
$normal_condition = db_and();
$normal_condition->condition('type', 'taxonomy_term', '<>');
$condition = db_or();
$condition->condition($node_condition);
$condition->condition($normal_condition);
$query->condition($condition);
}
}
Cheers
Tom
Comment | File | Size | Author |
---|---|---|---|
#2 | removed_deprecated_db_or_db_and_2985257-2.patch | 989 bytes | blacklabel_tom |
Comments
Comment #2
blacklabel_tom CreditAttribution: blacklabel_tom at Reason Digital commentedPatch attached.
Comment #3
blacklabel_tom CreditAttribution: blacklabel_tom at Reason Digital commentedComment #4
rivimeyComment #5
alex_optimLooks good.
Comment #6
pifagorComment #8
pifagor