You are here

function twitter_pull_render in Twitter Pull 6

Same name and namespace in other branches
  1. 6.2 twitter_pull.module \twitter_pull_render()
  2. 7.2 twitter_pull.module \twitter_pull_render()
  3. 7 twitter_pull.module \twitter_pull_render()

Retrieves appropriate tweets (by username, hashkey or search term) and passes over to the theming function with $themekey key passing tweets array along.

The rest of this module needs to make sure that corresponding theming functions exist, exist tweets array and perform desired theming.

Parameters

$twitkey: Twitter key, which can be a username (prepended with @), hashtag (prepended with #), or a search term.

$title: Title passed to the theme template.

$num_items: Number of tweets to retrieve from Twitter. Can't be more than 200.

$themekey: Theme key name to use for theming the output of Twitter API.

1 call to twitter_pull_render()
twitter_pull_block in ./twitter_pull.module
Implementation of hook_block() Note we are getting info about blocks from the twitter_pull_block_data function if at some time this data is store in the db (currently it is just in code) then we would want to add the config options in a $op = configure

File

./twitter_pull.module, line 60

Code

function twitter_pull_render($twitkey, $title = NULL, $num_items = NULL, $themekey = NULL) {

  //-- Set defaults if empty arguments were passed
  $title = empty($title) && $title != FALSE ? t('Related Tweets') : check_plain($title);
  $themekey = empty($themekey) ? 'twitter_pull_listing' : $themekey;
  $num_items = empty($num_items) ? twitter_pull_num_items() : $num_items;
  $tweets = twitter_pull_retrieve($twitkey, $num_items);
  $ret = theme($themekey, $tweets, $twitkey, $title);
  if (empty($ret) && !empty($tweets)) {
    $errmsg = t("Non-empty list of tweets returned blank space after applying theme function. Most probably you are passing invalid/unregistered theme key or tpl file corresponding to the theme key does not yet exist. Please fix the problem.");
    watchdog('Twitter Pull', $errmsg, array(), WATCHDOG_WARNING);
    $ret = t('Errors occured while trying to retrieve tweets. Please check Watchdog log messages.');
  }
  return $ret;
}