function mostpopular_get_items in Drupal Most Popular 6
Gets a themed list of the most popular items for a given service and interval.
Calls theme('mostpopular_items', $items, $service, $interval) to render the list of items.
Sends back a cookie so the $sid and $iid are remembered next time the block loads.
Parameters
integer $sid: The service ID of the currently-selected service.
integer $iid: The interval ID of the currently-selected interval.
3 calls to mostpopular_get_items()
- mostpopular_items_ajax in ./
mostpopular.block.inc - Returns a JSON object containing the items HTML in it's 'data' property.
- theme_mostpopular_block in ./
mostpopular.block.inc - The main theme function for the most popular block. This theme loads the javascript helper file and a basic stylesheet.
- theme_mostpopular_page in ./
mostpopular.block.inc - The main theme function for the most popular page. This theme loads the basic stylesheet but no javascript.
File
- ./
mostpopular.block.inc, line 63 - Defines all the pages, blocks and themes for rendering the most popular data to general users.
Code
function mostpopular_get_items($sid = NULL, $iid = NULL) {
$sid = (int) $sid;
$iid = (int) $iid;
if (empty($sid) || empty($iid)) {
return theme('mostpopular_items_none');
}
// Fetch the most popular items
$items = MostPopularItem::fetch($sid, $iid);
// Send back a cookie storing these values
setcookie('mostpopular', "{$sid}/{$iid}", strtotime("+1 year"), url(''));
return theme('mostpopular_items', $items, $sid, $iid);
}