0

I am using the Entity PDF plugin in Drupal 8, that does a good job in exporting to PDF nodes, but seems to exclude other scenarios such as Search Result list.

Anyone can provide some hints how would a PDF export be implemented for search results?

1

You can use hook_entity_view_alter() to hidden PDF export link. Sample

<?php

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

function examples_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $type = $entity->getType();
  $mode = $display->getMode();
  //Replace node type with text **page**
  if ($type == 'page' && $mode == 'search_result') {
    unset($build['entity_print_view']);
  }
}
1
  • Actually I did not want to hide, but create a HTML template that would later be pushed to the PDF generator. THe hooks helps in locating a section to place a link...
    – Al-Punk
    Aug 30 '16 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.