Skip to main content
Improves post formatting.
Source Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Multiple level of tab in Drupal 8 Why multilevel dynamic local tasks doesn't work?

I want to have tabs, but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253link to learn about local tasks.

Update: My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: modulelinks.configure tab_root_id: moduletasks.configure deriver: 'path to deriver'yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver' 

All the mentioned routes have been declared in *.routing.yml*.routing.yml file.

Multiple level of tab in Drupal 8

I want to have tabs but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253 to learn about local tasks.

Update: My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver'

All the mentioned routes have been declared in *.routing.yml file.

Why multilevel dynamic local tasks doesn't work?

I want to have tabs, but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link to learn about local tasks.

My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver' 

All the mentioned routes have been declared in *.routing.yml file.

Bumped by Community user
edited tags
Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284
deleted 68 characters in body
Source Link
user2750995
  • 193
  • 2
  • 11

I want to have tabs but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253 to learn about local tasks.

Update: My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver'

All the mentioned routes have been declared in *.routing.yml file. Does anyone willing to answer this question needs more information?

I want to have tabs but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253 to learn about local tasks.

Update: My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver'

All the mentioned routes have been declared in *.routing.yml file. Does anyone willing to answer this question needs more information?

I want to have tabs but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) { $this->derivatives[$key]['title'] = $definition['title']; $this->derivatives[$key]['route_parameters'] = array('module_format' => $key); $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key; if($key == 'xyz') { $key = 'newkey'; $this->derivatives[$key]['title'] = 'newkey'; $this->derivatives[$key]['route_name'] = 'module.newkey'; $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz"; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } 

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253 to learn about local tasks.

Update: My module.links.tasks.yml file looks like this:

module.format_configure: title: 'Configuration' base_route: module.configure tab_root_id: module.configure deriver: 'path to deriver'

All the mentioned routes have been declared in *.routing.yml file.

added 68 characters in body
Source Link
user2750995
  • 193
  • 2
  • 11
Loading
added 68 characters in body
Source Link
user2750995
  • 193
  • 2
  • 11
Loading
added 210 characters in body
Source Link
user2750995
  • 193
  • 2
  • 11
Loading
Formatted text
Source Link
Alfred Armstrong
  • 4.1k
  • 1
  • 15
  • 23
Loading
Source Link
user2750995
  • 193
  • 2
  • 11
Loading