0

How can I add a Preview in JSON local task?

My link is exactly the same of entity.node.canonical, but I have to add a query string (?_format=json). I know how to add the local task, but I don't know how to append the query string to the URL.

1 Answer 1

1

You need to configure URL options in links.task.yml file. See Url::fromUri for details.

your_module.export:
  title: Export
  route_name: entity.node.canonical
  options:
    query: {_format: json}
  base_route: entity.node.canonical

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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