0

In my custom module I want to create menu with the name "child/%" is it possible. When I create menu "child/test", whenever I load the page http://localhost/project/child/test it gives error page could not found. so if I run http://localhost/project/%E2%80%8Bchild/test like this it is working. Its confusing, Kindly clarrify.

Thanks, John.

  • Can you please show the code? – Fernando Pap Mar 8 '18 at 14:32
0

try to follow this code

<?php
/**
 * Implements hook_menu().
 */
function example_menu() {
  // In this example, the third parameter will be passed.
  $items['admin/example/%'] = array(
    'title' => 'Example of first parameter being passed',
    'description' => 'This has a page arguments index of two because the wildcard occurs at the 3rd parameter',
    'page callback' => 'one',
    'page arguments' => array(2),
    'access arguments' => array('access administration pages'),
  );
  // The third and fourth parameters are being passed, hence we need to create an array with values 2 and 3 for the page arguments key
  $items['admin/example/%/%'] = array(
    'title' => 'Example of multiple parameters being submitted',
    'description' => 'Example of multiple parameters being submitted',
    'page callback' => 'two',
    'page arguments' => array(2, 3),
    'access arguments' => array('access administration pages'),
  );

  return $items;
}

/**
 * One parameter being passed.
 */
function one($one) {
    return $one;
}

/**
 * Two parameters being passed.
 */
function two($one, $two) {
    return $one . ' ' . $two;
}

Thank You.

Your Answer

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

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