2

while I create node by PHP, I use this:

$node->menu['enabled'] = true;
$node->menu['link_title'] = $node->title;

but it puts link in 0 depth of the menu. It doesn't care for "Default parent" selected for content type. Neither this works:

$node->menu['parent'] = "menu-global-menu:961";

How to select parent then?

3

It looks like you need to set $node->menu['plid'] = "961"; to set the parent node.

You can have a look through the menu_link_save doco to get an idea of what is going on, or there is a smaller code snippet on this blog that explains in a simple, fast way.

As a side note, you can use node_object_prepare($node); to set default values after setting your node type, which should take care of your default menu parent. I've found this guide helpful with programmatic node creation.

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.