Skip to content
This repository was archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
MSS-162: Changed default sorting to last created, but made it configu…
Browse files Browse the repository at this point in the history
…rable as well.
  • Loading branch information
bertramakers committed May 20, 2015
1 parent ed86f71 commit af02ccb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion culturefeed_sitemap/culturefeed_sitemap.module
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ function culturefeed_sitemap_get_entries($type, $subtype = null) {
);
$type = $types[$type];

$sort = culturefeed_sitemap_sort_config();

$parameters = array();
$parameters[] = new \CultuurNet\Search\Parameter\Query('*:*');
$parameters[] = new \CultuurNet\Search\Parameter\Rows(100);
$parameters[] = new \CultuurNet\Search\Parameter\FilterQuery('type:' . $type);
$parameters[] = new \CultuurNet\Search\Parameter\Sort('lastupdated', \CultuurNet\Search\Parameter\Sort::DIRECTION_DESC);
$parameters[] = new \CultuurNet\Search\Parameter\Sort($sort['column'], $sort['direction']);

if ($subtype) {
$parameters[] = new \CultuurNet\Search\Parameter\FilterQuery('category_id' . ':(' . $subtype . ')');
Expand All @@ -197,6 +199,28 @@ function culturefeed_sitemap_get_entries($type, $subtype = null) {
}
}

/**
* Returns sorting configuration.
*
* @return array
* - column: column to sort
* - direction: asc or desc
*/
function culturefeed_sitemap_sort_config() {
$column = variable_get('culturefeed_sitemap_sort_field', 'creationdate');
$direction = variable_get('culturefeed_sitemap_sort_direction', \CultuurNet\Search\Parameter\Sort::DIRECTION_DESC);

if ($direction != \CultuurNet\Search\Parameter\Sort::DIRECTION_DESC &&
$direction != \CultuurNet\Search\Parameter\Sort::DIRECTION_ASC) {
$direction = \CultuurNet\Search\Parameter\Sort::DIRECTION_DESC;
}

return array(
'column' => $column,
'direction' => $direction,
);
}

/**
* Prints the XML for a urlset sitemap.
*
Expand Down

0 comments on commit af02ccb

Please sign in to comment.