Browse Source

Adds limit to overboard catalog

pull/40/head
nonmakina 3 years ago
parent
commit
a3e2af403b
  1. 7
      templates/themes/catalog/info.php
  2. 11
      templates/themes/catalog/theme.php

7
templates/themes/catalog/info.php

@ -97,6 +97,13 @@
'default' => 'overboard',
'comment' => 'Fill in the location of the overboard directory. Default is \'overboard\' which corresponds to ./overboard'
);
$theme['config'][] = Array(
'title' => 'Max posts in catalog overboard',
'name' => 'overboard_limit',
'type' => 'text',
'default' => '350',
'comment' => 'The maximum number of thread that will appear in the overboard catalog'
);
// Unique function name for building everything
$theme['build_function'] = 'catalog_build';

11
templates/themes/catalog/theme.php

@ -357,12 +357,15 @@
} else {
$sql = '';
foreach ($boards as $board) {
$sql .= $this->buildThreadsQuery($board);
$sql .= '('. $this->buildThreadsQuery($board) . ')';
$sql .= " UNION ALL ";
}
$sql = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $sql);
$result = query($sql) or error(db_error());
$threads = $result->fetchAll(PDO::FETCH_ASSOC);
$sql = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC LIMIT :limit', $sql);
$query = prepare($sql);
$query->bindValue(':limit', $settings['overboard_limit'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
$threads = $query->fetchAll(PDO::FETCH_ASSOC);
// Save for posterity
$this->threadsCache[$board_name] = $threads;
}

Loading…
Cancel
Save