The title says it.

This is part of #1823450: [Meta] Convert core listings to Views

Comments

oadaeh’s picture

Issue tags: +VDC

Forgot the tag.

Kars-T’s picture

Status: Active » Closed (duplicate)

Hi

I am closing this issue because it is strongly related to #2020387: Convert "Active forum topics" block to a View

Take a look at both queries:

    $query = db_select('forum_index', 'f')
      ->fields('f')
      ->addTag('node_access')
      ->addMetaData('base_table', 'forum_index')
      ->orderBy('f.created', 'DESC')
      ->range(0, $this->configuration['block_count']);

    $query = db_select('forum_index', 'f')
      ->fields('f')
      ->addTag('node_access')
      ->addMetaData('base_table', 'forum_index')
      ->orderBy('f.last_comment_timestamp', 'DESC')
      ->range(0, $this->configuration['block_count']);

Both are so similar we should do one view with multiple displays.

And both are bound to

/**
 * Render API callback: Lists nodes based on the element's #query property.
 *
 * This function can be used as a #pre_render callback.
 *
 * @see \Drupal\forum\Plugin\block\block\NewTopicsBlock::build()
 * @see \Drupal\forum\Plugin\block\block\ActiveTopicsBlock::build()
 */
function forum_block_view_pre_render($elements) {
  $result = $elements['#query']->execute();
  if ($node_title_list = node_title_list($result)) {
    $elements['forum_list'] = $node_title_list;
    $elements['forum_more'] = array('#theme' => 'more_link', '#url' => 'forum', '#title' => t('Read the latest forum topics.'));
  }
  return $elements;
}

We an delete this function after conversion. But if we have two issues depending on this we can't.

So to close one of these issues makes sense to me.

Kars-T’s picture

Double post ...