123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- # @Author: Bachir Soussi Chiadmi <bach>
- # @Date: 13-12-2017
- # @Email: bachir@figureslibres.io
- # @Filename: edlp_corpus.routing.yml
- # @Last modified by: bach
- # @Last modified time: 20-12-2017
- # @License: GPL-V3
- /**
- * Implements hook_theme().
- */
- function edlp_corpus_theme($existing, $type, $theme, $path) {
- // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
- return array(
- 'blockentrees' => array(
- // 'render element' => '',
- 'file' => 'blockentrees.inc',
- 'variables' => array(
- 'entrees_items' => array(),
- ),
- ),
- );
- }
- /**
- * hook_entity_extra_field_info()
- *
- */
- function edlp_corpus_entity_extra_field_info(){
- $extra = [];
- $extra['taxonomy_term']['entrees']['display']['index'] = [
- 'label' => t('Index'),
- 'description' => 'Display index of all documents tagued with the term',
- 'weight' => 99,
- // 'visible' => FALSE,
- ];
- return $extra;
- }
- /**
- * Implements hook_ENTITY_TYPE_view().
- * @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8
- */
- function edlp_corpus_taxonomy_term_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
- $index_display_settings = $display->getComponent('index');
- if (!empty($index_display_settings)) {
- // dpm($entity);
- // dpm($entity->id());
- $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
- $query = \Drupal::entityQuery('node')
- ->condition('status', 1)
- ->condition('type', 'enregistrement')
- ->condition('field_entrees', $entity->id());
- $documents_nids = $query->execute();
- $documents = entity_load_multiple('node', $documents_nids);
- $documents_list = array (
- '#theme' => 'item_list',
- '#items' => [],
- );
- foreach($documents as $doc){
- $documents_list['#items'][] = $view_builder->view($doc, 'index');
- }
- // And the last step is to actually build the tree.
- $build['index'] = array(
- '#type'=>"container",
- '#attributes'=>array(
- 'class'=>'index'
- ),
- 'label'=>array(
- '#type' => 'container',
- "#markup"=> t("Index"),
- '#attributes'=>array(
- 'class'=>'field__label'
- ),
- ),
- 'documents'=> $documents_list
- );
- }
- }
- /**
- * Implements hook_page_attachments().
- * @param array $attachments
- */
- // function edlp_corpus_page_attachments(array &$attachments) {
- // //add here any conditions if you need to limit the pages
- // if (\Drupal::service('path.matcher')->isFrontPage()) {
- // // $attachments['#attached']['library'][] = 'edlp_corpus/corpus';
- // // $attachments['#attached']['drupalSettings']['basepath'] = base_path();
- // // $attachments['#attached']['drupalSettings']['pathtoedlpcorpus'] = base_path() . drupal_get_path('module', 'edlp_corpus');
- // // $attachments['#attached']['drupalSettings']['pathtotfiles'] = PublicStream::basePath();
- // }
- // }
|