Score:0

Route name returns 404 despite working view

cz flag

I'm assigning breadcrumbs based on the view route names using the following code in hook_preprocess_breadcrumb().

$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name == 'view.news_list.main') {
  // Declare breadcrumbs.
}

My problem occurs with one of my views. For some reason, getting the route on the view returns system.404 despite the view being shown correctly. Why is this happening?

I forgot to say the view is set to the front page. For some reason, that's when the error started. Site is also multilingual, Japanese being the default.

misterdidi avatar
de flag
Do you have any specific configuration for this one view? Like access resctrictions or contextual filters and if so, does your issue appear for specific values only (/example/1/2) or for any values?
trashpanda avatar
cz flag
@misterdidi No contextual filters, relationships, or access restrictions, just normal filter criteria.
Meera avatar
cn flag
Does your view preview work? If yes, comment the code for breadcrumb and check whether the view displays or not.
apaderno avatar
us flag
Welcome to Drupal Answers! Where did you put that code? What is the exact string the code is using in `if ($route_name == 'this route name') { /* */ }`? I doubt you are looking for a route whose name is *this route name*.
trashpanda avatar
cz flag
@apaderno Thanks for the welcoming! I put the code in hook_preprocess_breadcrumb in my theme file. The exact string code is `$route_name == 'view.news_list.main'`. I used the code above just as a placeholder.
trashpanda avatar
cz flag
@Meera Yes, the view preview works. The view displays as well. My problem is that the route name returns system.404 despite the page rendering correctly.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.