diff --git a/theme/templates/elasticsearch_results.tpl.php b/theme/templates/elasticsearch_results.tpl.php new file mode 100644 index 00000000..4de732a3 --- /dev/null +++ b/theme/templates/elasticsearch_results.tpl.php @@ -0,0 +1,39 @@ + +
+
+
+
+ title ?>
+
+
+
+ title, $row->url) ?>
+
+
+ Content type: type ?>
+
+ content)): ?>
+ content ?>
+
+
+
+
+
+ url, 0, 40) . (strlen($row->url) > 40 ? '...' : '') ?>
+
+
+
+
+ url, '/'));
+ $url = substr($url, 0, 40) . (strlen($url) > 40 ? '...' : '')
+ ?>
+ url, [
+ 'attributes' => [
+ 'class' => ['text-muted'],
+ ],
+ ]) ?>
+
+
+
' . $item->highlight . '
'; + // $row .= '' . $item->highlight . '
'; + $row->content = $item->highlight; } - $rows[] = [$row]; + $rows[] = $row; } - $output = theme('table', [ - 'header' => [], + // $output = theme('table', [ + // 'header' => [], + // 'rows' => $rows, + // 'attributes' => [ + // 'id' => 'es-search-results-table', + // ], + // ]); + $output = theme('elasticsearch_results', [ 'rows' => $rows, - 'attributes' => [ - 'id' => 'es-search-results-table', - ], + 'base_url' => $base_url ]); if ($pager) { @@ -427,4 +453,4 @@ function get_table_search_result_table($search_results, $index_name, $total) { $output .= theme('pager', ['quantity', $total]); return $output; -} \ No newline at end of file +} diff --git a/tripal_elasticsearch.module b/tripal_elasticsearch.module index 9deaf620..8f07bf8a 100644 --- a/tripal_elasticsearch.module +++ b/tripal_elasticsearch.module @@ -337,6 +337,17 @@ function tripal_elasticsearch_theme($existing, $type, $theme, $path) { 'render element' => 'content', 'path' => "$path/theme/templates", ], + 'elasticsearch_results' => [ + 'template' => 'elasticsearch_results', + // 'render element' => 'elements', + 'path' => "$path/theme/templates", + 'variables' => [ + // The results array + 'rows' => [], + // The base url of the site + 'base_url' => null + ] + ], ]; return $themes; @@ -575,6 +586,7 @@ function tripal_elasticsearch_block_view($delta = '') { * tripal_elasticsearch_search_results_category_page_callback * * @param string $node_type Category name + * @throws Exception */ function tripal_elasticsearch_web_search_results_page_callback($node_type = '') { $keyword = isset($_GET['search_box']) ? $_GET['search_box'] : '';