0

I'm trying to add a line showing the last updated time for my RSS aggregator feed block (essentially the checked timestamp field from the aggregator_feed in a formatted manner).

I'm not able to find a preprocess function that lets me get this value.. the closest i got was implementing

function mm_theme2_aggregator_block_item($item, $feed = 0) {

  if($item->fid) {
    $fetch_modified_time = "SELECT `checked` FROM {aggregator_feed} WHERE `fid` = %d";
     $feed_last_modified_time = db_result(db_query($fetch_modified_time, $item->fid));
    }
    $last_modified = 'Last Modified time is ' . date('D M d h:i:s T Y', $feed_last_modified_time);
  $output .= '<a class="rssContent" href="'. check_url($item->link) .'" target="_blank">'. check_plain($item->title) ."</a>\n";
  return $output;
}

where i'm not sure how to pass on this value to my $block or to $variables. Also this method iterates for each feed item and it'd be unwise to get the same value executed multiple times.

I'm pretty certain there's a drupal based way to get what i desire and am missing something.

Any help/support on this would be really helpful.

Thanks in advance

1 Answer 1

0

I implemented the above requested functionality by using a template_preprocess_block and adding the fetched variable to the $variables['block']. Code for the same as below:

    function my_theme_preprocess_block (&$variables) {
      // fetch last updated time for feed 1 only other feeds don't need this value
      if (($variables['block']->module == 'aggregator') && ($variables['block']->delta == 'feed-1')) {
        $last_updated_timestamp = db_result(db_query("SELECT `checked` FROM {aggregator_feed} WHERE `fid` = 1"));
        if (!empty($last_updated_timestamp)) {
          $variables['block']->last_updated_time = 'Last updated on ' . date('D M d g:i:s T Y', $last_updated_timestamp);
        }
      }
}

but this seems to look bad as i'm hardcoding my feed id in the query besides the fact that i'm using a query in template.php but it works.

Leaving this question hoping someone could top with a better solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.