Questions tagged [routes]

Using a term introduced in Drupal 8, routes are the paths to which modules respond.

Filter by
Sorted by
Tagged with
1
vote
2answers
965 views

How to programmatically add menu for content type?

E.g. article has main menu as default, I want to add (and remove) second menu as available to article content type in my unit tests, how can I do it?
0
votes
1answer
174 views

Show/hide menu link based on changing custom $tempStore value

I'd like to show/hide a main-menu link based on a $tempStore variable the user can set and modify during their session, i.e. user sets $tempStore['vlaue'] = 0; --> menu link is hidden user sets $...
1
vote
1answer
162 views

Default entity ID for _entity_view in routing.yml

I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view ...
0
votes
4answers
6k views

Expand sub-menus on hover in a menu block

I need to show menus expanded in the sidebar. I used the menu blocks to show the submenus. But now the problems is when I hover on the parent menu initially it is not showing the submenus which was ...
0
votes
1answer
492 views

How to add a default controller to the <front> route?

Is it possible to add a default controller to the '<front>' route? There's no default controller defined in system.routing.yml. I'm trying to get a handle on it by using the following code: &...
0
votes
0answers
94 views

Custom ParamConverter doesn't work (doesn't give error but return isn't what it should)

I'm learning Drupal8 (for the first time, no Drupal7 or previous knowledge) on a local Vagrant VM and have come up against this little problem. I'm sorry if it's kind of a noob question but I wasn't ...
0
votes
2answers
1k views

Display main menu expanded in footer, drop down in header

I'm trying to show the Main menu in two places, once as a dropdown menu at the top, then again in the footer as a fully expanded (non-collapsible) set of links. I'm using the Superfish module to ...
0
votes
2answers
44 views

What can Menus do that Taxonomy cannot?

'Comments', 'Users', 'Taxonomy' are Entity Types because they each define their own sets of required fields. I am having a discussion with my boss where I am arguing that 'Menu' are really just a ...
1
vote
1answer
402 views

Custom route using access check error with arguments

I have a custom route that needs to check if a user can create a certain group_node:article content inside a group (from the group module 8.x-1.0-rc2). The setting is as follows: mymod.routing.yml ...
1
vote
1answer
264 views

Can I get Entity Cache Tags from a Route?

If I have a node object I can use $node->getCacheTags() to get the cache tags for the node object, and I can do the same for other entities. Is there a way for me to do something similar with a ...
0
votes
1answer
255 views

Use JSON instead HTML for access denied on some custom paths

I create a small API for one project using Bathic Authentication. The API consists of some custom paths defined in routes in a custom module. Using JsonResponse() in the controller we send back a JSON ...
0
votes
1answer
206 views

Dynamic local tasks to the same route with slug

I have a route set up with a slug accepting taxonomy terms (routing.yml): example.column: path: '/column/{taxonomy_term}' I would like to add (secondary, although that's not important) local task ...
2
votes
1answer
130 views

Why is my custom parameter converter class not used?

I start banging my head on the table, the wall or anything else... please help me. Here is my my_module.routing.yml: my_module.api.validate_coupon: path: '/api/v1/{coupon_code}/validate' ...
0
votes
1answer
32 views

How to redirect to a specifi page of a view?

Here is the code of a custom form: public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $status = parent::save($form, $form_state); $values=$...
1
vote
4answers
3k views

Does anyone knows a good menu module? [closed]

I'm looking for a menu module which would show a menu tree like: Menu level 1 (Container) |-------Menu level 2 |-------Menu level 2 |-------Menu level 2 |-------Menu level 2 |-----...
21
votes
2answers
22k views

What's the difference between access arguments and access callback?

What's the difference between access arguments and access callback? Suppose I set the access callback to 'user_access', and array('custom permission') is the value for the access arguments. What ...
2
votes
1answer
61 views

Is it possible or/and how to restrict access to the block on th certain page using route name?

I am trying to restrict access to the block to be accessible only on the route:entity.user.canonical route. Is it possible to define that on the block edit form?
3
votes
1answer
3k views

How to return JSONP from a menu callback

I can create JSON output using a menu hook using the drupal_json_output callback. Example: $items['page/%/json'] = array( 'access callback' => TRUE, 'page callback' => '...
0
votes
2answers
94 views

Show url attibuts in twig

I have this in my routing page function_adh_apport.adh_apport: path: '/collecte/apports/{date}' defaults: _controller: '\Drupal\function_adh_apport\Controller\RapportsController::filtrer' ...
2
votes
1answer
3k views

Correct way to use hook_menu_alter

What is the correct way of using hook_menu_later. I did this in my module to redirect (see also redirect in hook_init makes body text disappear): function MYMODULE_menu_alter(&$items) { $items[...
1
vote
2answers
647 views

How do I convert hook_menu()? [closed]

I am having site built in Drupal 7 and in future I want to migrate my site to Drupal 8. How can I write hook_menu() and hook_menu_alter() to routing.yml files?
1
vote
1answer
292 views

How do I modify a custom entity delete form?

I have a custom entity "Possession" that I created that has a non-standard edit form route to help facilitate a decending url structure. The routing for the edit form looks like this: entity....
0
votes
1answer
259 views

Menu access callback function called multiple times

I have following menu defined with access callback function. As You can see this is a hack so I can use REST via GET ( normally Services do not offer this ). All my endpoints are defined /rest/api/[...
3
votes
2answers
1k views

how to restrict access in routing.yml based on roles

I know how I to restrict access in the routing.yml file based on permissions, but how can I do it based on roles? This is how to do it by permissions: requirements: _permission: 'access ...
2
votes
0answers
209 views

Detail page route gives error

In my_module.routing.yml my_module.detail: path: '/module/{id}' defaults: _controller: '\Drupal\module\Controller\DetailController::view' requirements: _access: 'TRUE' In template twig ...
1
vote
1answer
51 views

Can a Event Service be coupled to a route

I have created a custom service and have hooked into the "event_subscriber" via tags in my custom service.yml demo_api.exception_handler_subscriber: class: Drupal\demo_api\Response\Handler ...
0
votes
1answer
20 views

Externally Requesting Browser Test Created URL for Relaxed Replication

I am trying to write a browser test for for a workspace replication via relaxed web services using the multiversion, replication and relaxed modules. For this purpose I set up an external Drupal ...
2
votes
2answers
485 views

How do I print a menu with links generated by my custom module?

If I use theme('links', array('links' => menu_navigation_links('main-menu'), 'attributes' => array('class'=> array('links', 'main-menu')) )); It will print the links in my Main Menu. I need ...
2
votes
1answer
95 views

Why is my form only redirected sometimes?

I want to have a user register, and be redirected to a node create form. Here's how I'm doing it thus far. The setup I have a route, my_module.register that is handled by MyController::register(). ...
0
votes
1answer
273 views

Multiple aliases per node (and active trail)

Our site is split down the middle for tenants and landlords. But we have content the is the same for both such as "how to report antisocial behaviour". User would normally navigate something like "...
0
votes
2answers
38 views

Custom username paths?

I want to be able to create paths like this: /guy1 /guy2 /guy3 It's easy enough if I want /profile/guy1 ... then I can just do this: gg_profile.viewUserProfile: path: '/profile/{username}' ...
3
votes
3answers
626 views

Can I conditionally hide a route (e.g. action / local task)

Consider an action button on a custom entity's canonical page: mymodule.actions.yml: entity.item.action: route_name: entity.item.action title: 'Do something' appears_on: - entity.item....
0
votes
1answer
24 views

Can access arguments only be specified once for all sub-routes?

For example: I would start off by setting this. $items['admin'] = array( 'access arguments' => array('administer users'), 'type' => MENU_NORMAL_ITEM, ); But the anytime after I use admin in ...
0
votes
1answer
42 views

Change routing behaviour for non-existent entities

For my custom entity type called item, I would like to set up routes such that the path: /item/{item} views the entity as normal, if it exists if it doesn't exists, redirects to the create form The ...
13
votes
5answers
11k views

How to get route name of a view page?

In my custom submit handler I want to redirect to a view page Url, let's suppose my view name is team and its path is /admin/team, I find out I should use $from_state->setRedirect('route'); but ...
2
votes
1answer
39 views

8 - Is It Possible To Create Routes Through The Admin

Question: Is there a way for users to create routes in the admin? Issue: I have a bunch of nodes and tax terms that are being used in Views but no where else. They shouldn't be accessible to the ...
3
votes
1answer
2k views

Setting a View's Menu Item to a Sub-Menu

I'm using Drupal 7.10 and Views 3.1. This seems like it should be simple but I can't find an answer. I have a menu structure similar to the following: Main > About Us > History ...
1
vote
2answers
2k views

Create route that returns XML Feed [closed]

How do I create a page that returns an XML feed?
1
vote
1answer
4k views

Adding a span tag to main menu items

Possible Duplicate: How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu I tried the code found in How do I insert a <span> </span> tag ...
0
votes
0answers
118 views

Access denied to admin on custom module

I get access denied to admin user in my custom module. This is my routing yml file: operatordb: path: operator-database defaults: _form: \Drupal\operatordb\Form\OperaDBForm _title: '...
0
votes
0answers
61 views

Customize CMS menu

I have created a menu from the Drupal CMS (admin > structure > menu). Now I want to change the title of the same programatically. Is it possible, if so how? I have tried hook_menu_alter, ...
7
votes
2answers
17k views

Pass arguments using hook_menu

I would build a confirmation screen. So I initialized the path in the hook_menu as it should be but for some reason, the argument $node isn't send with the function... What am I doing wrong? This is ...
5
votes
1answer
1k views

How do I define a Route with multiple different paths?

Does Drupal's routing system support a regular expression or other means for multiple route paths? I have a route that I would like to be able to hit from two different endpoints, /api/v1/foo and /api/...
0
votes
3answers
53 views

How do I make the page created from my module visible only to anonymous users?

I programatically created a page using the following code. /** * Implements hook_menu(). */ function page_prog_menu() { $items['page_prog/custom'] = array( 'title' => 'My Custom page', ...
0
votes
1answer
55 views

routing.yml file doesn't work

I'm working on an existing Drupal 8 site. I'm changing anything in routing.yml. In a routing.yml file I have the following. user_profile_update.callback: path: '/user-update' defaults: ...
0
votes
1answer
48 views

Throw entity field value from submission to route path?

I have created two entities and I want to connect them by route. my edit route is: entity.entity_two.edit_form: path: '/property/configuration/communication/{entity_one}/variant/{entity_two}/edit'...
0
votes
4answers
358 views

Can we use the same path for a different route?

Are we allowed to use the same path for two different routes? For example, can I use the following code? function mymodule_menu() { $items['myUrl/dboperation'] = array( 'title' => 'some ...
102
votes
1answer
40k views

How should I implement hook_menu()?

What are the fundamentals of implementing hook_menu()? I would like to see the basics covered in a single question, to avoid having to answer the same similar but different questions over and over.
5
votes
2answers
9k views

How and where do I programmatically add a menu to the Navigation menu?

I want to add menu items to the Navigation menu dynamically, depending on certain states (example: user is logged in, etc). I assume I do this in theme_preprocess, but I can't seem to find the var to ...
5
votes
6answers
4k views

How to add html tags in drupal 7 menu?

I would like to add <br> tag or &nbsp; character to html menu, but when I type Home <br> Page, it does display as plain text, but I want to break that words by two lines. How can I ...