Drupal 6: Adding submenu items to a menu item?

I have a hook:

function node_field_link_menu() { $items['order_food'] = array( 'title' => 'Products', 'page callback' => 'node_field_link_products_page', 'access callback' => TRUE, 'menu_name' => 'primary-links', 'type' => MENU_NORMAL_ITEM, ); return $items; } 

This gives me my menu item, and I am pleased with it. The problem is that I want the items under this menu item, so I get:

 - Products - Product 1 - Product 2 - Product 3 - Product 4 

I read that you can use "plid", but the problem is that in this context I do not know what PLID is, because I just created a parent. Therefore, I cannot do this:

 function node_field_link_menu() { $items['order_food/procuct1'] = array( 'title' => 'Product 1', 'page callback' => 'node_field_link_products_page1', 'access callback' => TRUE, 'menu_name' => 'primary-links', 'type' => MENU_NORMAL_ITEM, 'plid' => XXX?, ); return $items; } 

So, how can I add another menu item under the menu item that I created in Drupal 6?

+5
source share
1 answer

What you did should work without a "plid". Drupal recognizes the path template and does the job for you. If you have the path "order_food" and the path "order_food / product1", product1 will be a child of "order_food". All you have to do after creating the menu is to clear the Drupal cache.

Just tried this on a new Drupal 6 instance, cleared the cache, and I see that it works:

 $items['order_food'] = array( 'title' => 'Product', 'page callback' => 'node_field_link_products_page', 'access callback' => TRUE, 'menu_name' => 'primary-links', 'type' => MENU_NORMAL_ITEM, ); $items['order_food/product1'] = array( 'title' => 'Product1', 'page callback' => 'node_field_link_products_page1', 'access callback' => TRUE, 'menu_name' => 'primary-links', 'type' => MENU_NORMAL_ITEM, ); 

Opening the URL "admin / build / menu-customize / primary-links" will show Product1 as a child of the Product.

0
source

Source: https://habr.com/ru/post/1235673/


All Articles