codekarim is just a bunch of reminders for fenuapps.com
$header = array( array('data' => t('ID'), 'field' => 'nid'), array('data' => t('type'), 'field' => 'type'), array('data' => t('title'), 'field' => 'title', 'sort' => 'desc') ); $query = \Drupal::database()->select('node_field_data','loc'); $query->fields('loc', array('nid', 'type', 'title')); // $query->addField('loc','name','name_alias'); $table_sort = $query->extend('Drupal\Core\Database\Query\TableSortExtender')->orderByHeader($header); $pager = $table_sort->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(10); $result = $pager->execute(); foreach($result as $row) { // $rows[] = array('data' => (array) $row); $url = Url::fromRoute('entity.node.canonical', ['node' => $row->nid], $options); //$url = $url->toString(); $link = Link::fromTextAndUrl($row->title, $url); $link = $link->toRenderable(); $outlink = render($link); $rows[] = array('data' => array($row->nid, $row->type,$outlink)); } $options = ['absolute' => TRUE]; $url = Url::fromRoute('entity.node.canonical', ['node' => 1], $options); //$url = $url->toString(); $link = Link::fromTextAndUrl("Node 1", $url); $link = $link->toRenderable(); $link['#attributes'] = array('class' => array('internal')); $outlink = render($link); $build = array( '#markup' => t('List of All locations').$outlink ); $build['location_table'] = array( '#theme' => 'table', '#header' => $header, '#rows' => $rows ); $build['pager'] = array( '#type' => 'pager' ); return $build;