I have read Multiple pages on the same dynamic path (node types) and Dynamic argument replacement (wildcard) but I don't think they cover my specific coversion need, or maybe I'm just too dense.

In 5.x we had two tabs on the content type add page, "Add" and "Import," that were done with this menu structure:

    $items[] = array(
      'path' => 'node/add/quotes',
      'title' => t('Quotes'),
      'access' => (user_access('create quotes') || user_access('import quotes') || user_access('edit own quotes'))
      );

    $items[] = array(
      'path' => 'node/add/quotes/add',
      'title' => t('Add'),
      'access' => (user_access('create quotes') || user_access('edit own quotes')),
      'type' => MENU_DEFAULT_LOCAL_TASK
      );

    $items[] = array(
      'path' => 'node/add/quotes/import',
      'title' => t('Import'),
      'access' => user_access('import quotes'),
      'type' => MENU_LOCAL_TASK
      );

In 6.x we are not to include "node/add." So how does this multiple tab set up work?

Comments

pwolanin’s picture

Your information is incomplete and unclear. Is that 5.x menu definition in the cached part? Is 'quotes' a node type or something else?

node types are added automatically as node/add/X, so don't define that path again. you probably need something like:


function quote_menu() {
    $items['node/add/quotes/add'] = array(
      'title' => 'Add',
      'access callback' => 'quote_add_access',
      'type' => MENU_DEFAULT_LOCAL_TASK
      );

    $items['node/add/quotes/import'] = array(
      'title' => 'Import',
      'access arguments' => array('import quotes'),
      'type' => MENU_LOCAL_TASK
      );

  return $items;
}

function quote_add_access() {
  return (user_access('create quotes') || user_access('edit own quotes'));
}

Note - do not use t(), define an access callback for anything complicated, the default access callback is user_access()

note that the normal access callback for node/add/quotes will be node_access('create', 'quotes').

---
Work: BioRAFT

nancydru’s picture

Yes, I know to leave out the t() calls. This is in the $may_cache section.

So, basically you're saying just yank out the original node/add path and leave the other two (with minor changes).

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

nancydru’s picture

Line 35: The node/add/$type menu items are now auto-generated by the menu system in 6.x. You should not declare them in your menu hook. See node/add is now menu generated. (Drupal Docs)

$items['node/add/quotes/add'] = array(

The complete menu set is:

  $items['node/add/quotes/add'] = array(
    'title' => 'Add',
    'access callback' => 'quote_add_access',
    'type' => MENU_DEFAULT_LOCAL_TASK
    );

  $items['node/add/quotes/import'] = array(
    'title' => 'Import',
    'access arguments' => array('import quotes'),
    'type' => MENU_LOCAL_TASK
    );

Coder flags both of them.

chx’s picture

we are not to include "node/add." <= I can't understand this. Someone told you to not include node/add? Where? what?

--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.

nancydru’s picture

It is stated several places that this path is added automatically and should not be coded. It's even in pwolanin's comment above, and flagged by the Coder module.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

pwolanin’s picture

Well. I think in this case you may need to ignore Coder or suggest a patch for it. The docs you are referencing (and from which the Coder rule may be derived) probably just don't anticipate local tasks being added to this page.

---
Work: BioRAFT

nancydru’s picture

I am already doing the former and plan on the latter.

Nancy W.

nancydru’s picture

Okay, the above stuff is working. Except that there is no regular node/add stuff included on the form for the "node/add/quotes/import" menu entry (it is there for the other). I assume this is because it is not a plain "node/add" path. Can this be fixed easily?

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

pwolanin’s picture

You still have to define all the usual hooks for a custom node type.

---
Work: BioRAFT

nancydru’s picture

This is an existing module that works just fine in 5.x. I'm just upgrading it to 6.x.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database