0

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.

6
  • 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?
    – misterdidi
    Jul 5 at 13:19
  • @misterdidi No contextual filters, relationships, or access restrictions, just normal filter criteria.
    – trashpanda
    Jul 6 at 1:23
  • Does your view preview work? If yes, comment the code for breadcrumb and check whether the view displays or not.
    – Meera
    Jul 6 at 7:45
  • 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.
    – apaderno
    Jul 6 at 8:22
  • @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
    Jul 6 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.