You are here

function theme_ed_classified_ads_block in Classified Ads 6.2

Same name and namespace in other branches
  1. 5.2 ed_classified_themefuncs.inc \theme_ed_classified_ads_block()
  2. 5 ed_classified_themefuncs.inc \theme_ed_classified_ads_block()
  3. 7.2 ed_classified_themefuncs.inc \theme_ed_classified_ads_block()

Theme an ads block

2 theme calls to theme_ed_classified_ads_block()
ed_classified_get_latest_ads_list in ./ed_classified_utils.inc
Get a list of latest ads for block use
ed_classified_get_popular_ads_list in ./ed_classified_utils.inc
Get a list of popular ads for block use

File

./ed_classified_themefuncs.inc, line 44
$ Simple text-based classified ads module.

Code

function theme_ed_classified_ads_block($ads, $display_timestamp = TRUE, $display_counter = FALSE, $display_ad_category = FALSE) {
  module_load_include('inc', 'ed_classified', 'ed_classified_utils');

  // var_dump($ads);
  $content = '';
  foreach ($ads as $x) {
    $content .= '<li class="classified-ad-item">' . l($x->title, drupal_get_path_alias('node/' . $x->nid), array(
      'attributes' => array(
        'title' => check_markup($x->teaser),
      ),
    ));
    if ($display_ad_category) {
      $term = _ed_classified_get_primary_category($x);
      if ($term) {
        $content .= ' <span class=\'classified-block-ad-term\'>' . l("({$term->name})", _ed_classified_make_category_path($term->tid)) . '</span>';

        // TODO: themeable function
      }
    }
    if ($display_timestamp) {
      $content .= ' <span class=\'classified-block-ad-age\'>(' . format_interval(REQUEST_TIME - $x->timestamp, 2) . t(' ago') . ') </span>';
    }
    if ($display_counter) {
      $content .= ' <span class=\'classified-block-ad-count\'>(' . $x->counter . ') </span>';
    }
    if (node_last_viewed($x->nid) < $x->changed) {
      $content .= theme_mark();
    }
    $content .= '</li>';
  }
  if (!empty($content)) {
    $content = '<div class="classified-ad-block item-list"><ul>' . $content;
    $content .= '</ul></div>';
  }
  return $content;
}