1

Suppose that I have a view that outputs a list of some content. Now I'd like to add some action buttons next to each content item, so that clicking these buttons triggers some custom action or redirect the user to another path (specific for that item).

I found a solution here that comes close to what I'd like to do, but that solution is based on D7 Add custom action buttons to view. Without repeating the content of this link, could someone let me know whether that approach is still valid/good practice for Drupal 8?

In case it is the solution, how would you implement the functionality of passing the $nid of a list item to a different form via POST when clicking one of the action buttons ? Would this be part of the function function query() {...} in step 5 of the link ? If so, how would you approach this ?

Are there solutions that might be better suited to D8?

4

Drupal 8 lets you add 'DropButtons' to your View, which looks really good in UI.

  1. add a 'Custom text' field for each action you want to provide - use 'exclude from display' and 'output as custom link'

  2. add a 'dropbutton' field and select your custom links to be shown in it

  3. profit

  • Thanks, that seems to be a good way to solve this. If you could help me with one more thing. Let's say I have a dropbutton now in each row. Is it possible when clicking the button to redirect to a form and pass a variable (e.g $nid) via POST ? – theuni Sep 18 '17 at 8:52

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.