By editor, 14 December, 2015 Question How to get arguments (parameters) from url in Drupal 8 ? Like $path_args = arg(); on Drupal 7. Example: $current_url = Url::fromRoute('<current>'); $path = $current_url->toString(); //OR of you want to get the url without language prefix $path = $current_url->getInternalPath(); $path_args = explode('/', $path); Method 2: (Get first argument from url on Drupal 8) $request = \Drupal::request(); $current_path = $request->getPathInfo(); $path_args = explode('/', $current_path); $first_argument = $path_args[1]; Tags Drupal 8 Code Add new comment Drupal 8 Url Tips. Get Name, Path, Args ... Comments1 You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically. Useful Answer Useful Answer!!! Reply
Comments1
Useful Answer
Useful Answer!!!