0

I used this code in Drupal 7 can access all parameter.

$items['hello'] = array(
      'page callback'     => 'hello_handler',
      'title'             => 'Hello page',
      'description'       => 'Hello description',
      'access callback'   => TRUE,
      'type'              => MENU_CALLBACK,
      'file'              => 'hello.inc',
    );

How I can access hello/pargs1/args2 in Drupal 8 url without page not found

In my drupal 8 code:

hello.hello_handler:
      path: '/hello'
      defaults:
        _controller: '\Drupal\hello\Controller\HelloController::hello_handler'
        _title: 'Hello page'
      requirements:
        _access: 'TRUE'

closed as too broad by kiamlaluno May 22 at 14:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Actually, 'access callback' => TRUE is for avoiding Drupal checks the user has access to the page, not to be able to access all the parameters in the URL. – kiamlaluno May 22 at 13:54
  • Without seeing the code used in Drupal 7, this question is too broad. It would also be preferable to see any code written in the tentative to convert Drupal 7 code in Drupal 8 code. – kiamlaluno May 22 at 14:00
1

Now it's in the routing.yml file at the root of your module :

Here an example :

example.routing.yml

example.page_form:
  path: '/example'
  defaults:
    _form: '\Drupal\example\Form\ExampleForm'
    _title: 'Example'
  requirements:
    _access: 'TRUE'

You can restrict by role too for example :

  requirements:
    _role: 'administrator+editor'

Or by permission :

  requirements:
    _permission: 'access administration pages'

Or by custom permission :

  requirements:
    _access_custom_check: 'true'

Not the answer you're looking for? Browse other questions tagged or ask your own question.