-1

I am currently creating a module that allows generating PDFs based on arbitrary entities (or at least nodes). Multiple templates can be defined as config entities. This part already works. I have the config entity set up with create, edit and delete forms and the list.

Now I want to provide a link for each entity of any entity type (i.e. node) like example.com/node/[nid]/pdf/[template_id] that loads the defined template with ID [template_id], generates the PDF and downloads it directly.

What is the correct way? Should I just provide a link through the routing file or is it better to implement a plugin or a custom operation handler or .. I am new to D8 and so I am not aware of all possibilities.

Thanks, j

  • That's what controllers are for, getting parameters from a route and generating output. So yes, to get started you need a routing file, where you define the parameters and the controller class and method that should be called. – 4k4 Jan 30 '17 at 16:00
  • OK. Thanks for that. I just wanted to make sure that there is no "Drupal way" that allows extending the functionality of existing entities. I will try that and get back when it works. – schlicki Jan 30 '17 at 18:02
  • If you put your comment as answer I will accept it. It worked like you said. – schlicki Feb 11 '17 at 6:44
0

That's what controllers are for, getting parameters from a route and generating output. So yes, to get started you need a routing file, where you define the parameters and the controller class and method that should be called.

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.