K
K
Kirill Parasotchenko2016-01-29 16:18:42
PHP
Kirill Parasotchenko, 2016-01-29 16:18:42

Is there any limit on path length in drupal 7 hook_menu?

Hello!
Can someone tell me why the last callback in the code does not work? Does drupal have any restrictions on path length???

function image_watermark_menu() {

  $items = array();

  $items['admin/config/media/image_watermark/config_form'] = array(
      'title' => 'Image watermark settings',
      'description' => 'Image watermark settings',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('image_watermark_config_form'),
      'access arguments' => array('administer site configuration'),
      'file' => 'image_watermark.admin.inc',
  );

  $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
  $count = count(explode('/', $directory_path));
  $items[$directory_path . '/styles/%image_style/public/image_watermark_move'] = array(
      'title' => 'Generate image style',
      'page callback' => 'image_watermark_style_deliver',
      'page arguments' => array($count + 1, $count + 2, $count + 3, $count + 4),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
  );

  $items[$directory_path . '/styles/%image_style/public/image_watermark_no_watermark'] = array(
      'title' => 'Generate image style',
      'page callback' => 'image_watermark_style_deliver',
      'page arguments' => array($count + 1, $count + 2, $count + 3),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
  );

  $items[$directory_path . '/styles/%image_style/public/image_watermark/private/field/image'] = array(
      'title' => 'Generate image style',
      'page callback' => 'image_watermark_style_deliver',
      'page arguments' => array($count + 1, $count + 2, $count + 3),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
  );

  return $items;
}

I have apache2.4/php7/mysql5/drupal7

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Drupby, 2016-01-29
@drupby

In the database, the path field is varchar(255) - that's all the restrictions

K
Kirill Parasotchenko, 2016-01-31
@Taiyonoryoshiy

things turned out to be in the kernel constant MENU_MAX_PARTS = 9. and unfortunately there is no way to change the situation with the number of elements in the path ((

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question