That title is probably confusing but I can't think of a better one right now. I converted a module (ISBN2node) from D7 and it works fine now but the tabs to add its own content type all show up at the top of the main node/add page, like this:

How do I make the tabs only show up after choosing the "ISBN2node" content type to create? (It gets even worse if I also install a custom module that provides similar tabs ... then all of them show up at the top of this page!)

ETA: It also did this in D7, if that matters.

Accepted answer

That did work on Drupal 7, which has the same problem. The reason is that the base path for the tabs is 

node/add/isbn2node-book

Not

node/add/isbn2node_book

Do you have the ported module anywhere on github that I can install it locally and test why D7 worked and B did not?

Comments

So you want the tabs to only appear when someone opens the ISBN2Node creation form? 

Tabs (the technical name is "local tasks") are determined by hook_menu() by adding MENU_LOCAL_TASK and MENU_DEFAULT_LOCAL_TASK to the 'type' element of the correct menu item definition. Their placement depends on the path of the router items.

So, in your case, you need to post here the item definitions for all those tasks, and I can take a quick look to see if this is possible. It may not be possible to change them just by modifying hook_menu(). You may need to use hook_menu_local_tasks_alter() (which I've never done).

Yes, correct. Here are the defs:

  // Add ISBN book via lookup
  $items['node/add/isbn2node_book/isbn2node'] = array(
    'title' => 'ISBN book by lookup',
    'description' => 'Enter the ISBN for a book and populate an ISBN-book based on the data fetched.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('isbn2node_add_form'),
    'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,
    'access arguments' => array('add by isbn'),
    'weight' => 10,
  );

  // Bulk add ISBN books
  $items['node/add/isbn2node_book/bulk'] = array(
    'title' => 'ISBN book bulk import',
    'description' => 'Enter a series of ISBN and create nodes based on lookups.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('isbn2node_bulk_form'),
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('bulk add by isbn'),
    'weight' => 20,
    'file' => 'isbn2node.bulk.inc',
  );

  // Title search
  $items['node/add/isbn2node_book/title'] = array(
    'title' => 'ISBN title search',
    'description' => 'Search for books through titles.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('isbn2node_title_form'),
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('administer nodes'),
    'weight' => 30,
  );

Thank you.

OK, the answer is very simple. In those 3 items, change isbn2node_book to isbn2node-book

Hmm, I tried that but sadly it didn't change anything. Even after clearing caches :)

What is the reason for the isbn2node-book vs isbn2node_book?

That did work on Drupal 7, which has the same problem. The reason is that the base path for the tabs is 

node/add/isbn2node-book

Not

node/add/isbn2node_book

Do you have the ported module anywhere on github that I can install it locally and test why D7 worked and B did not?

leeksoup, unless I am misunderstanding you, my fix works perfectly in Backdrop. Please see below:

Add content page: no tabs!

Node creation form for ISBN2Node-book content type: tabs!!!!

Puzzled...

And this is the content of isbn2node_menu()

 

// Settings menu.

$items['admin/config/content/isbn2node'] = array(
'title' => 'ISBN to node',
'description' => 'Configure ISBN lookup.',
'page callback' => 'backdrop_get_form',
'page arguments' => array('isbn2node_settings_form'),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array('configure isbn2node'),

);


// Add ISBN book via lookup.

$items['node/add/isbn2node-book/isbn2node'] = array(

'title' => 'Look up by ISBN',

'description' => 'Enter the ISBN for a book and populate an ISBN-book record based on the data fetched.',

'page callback' => 'backdrop_get_form',

'page arguments' => array('isbn2node_add_form'),

'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,

'access arguments' => array('add by isbn'),

'weight' => 10,

);


// Bulk add books using a list of ISBNs.

$items['node/add/isbn2node-book/bulk'] = array(

'title' => 'ISBN book bulk import',

'description' => 'Enter a series of ISBN and create nodes based on lookups.',

'page callback' => 'backdrop_get_form',

'page arguments' => array('isbn2node_bulk_form'),

'type' => MENU_LOCAL_TASK,

'access arguments' => array('bulk add by isbn'),

'weight' => 20,

'file' => 'isbn2node.bulk.inc',

);


// Title / keyword search.

$items['node/add/isbn2node-book/title'] = array(

'title' => 'Title/ keyword search',

'description' => 'Search for books through keywords, e.g. title and author.',

'page callback' => 'backdrop_get_form',

'page arguments' => array('isbn2node_title_form'),

'type' => MENU_LOCAL_TASK,

'access arguments' => array('add by isbn'),

'weight' => 30,

);


// Add an ISBN book taking the ISBN from the URL.

$items['node/add/isbn2node_book/manual/%'] = array(

'title' => 'ISBN book with ISBN filled out',

'description' => 'Go to the form and fill out ISBN from URL.',

'page callback' => 'isbn2node_add_manual',

'page arguments' => array(4),

'type' => MENU_CALLBACK,

'access arguments' => array('administer nodes'),

);

 

Well ... I have no idea why you're getting different results from me. I will go through and double check all the items you've posted and report back.

I appreciate all your help!

And the answer is ... user error. Thanks again for your help!

ETA: I was actually working on a custom module that I based on ISBN2node. That changed the paths a bit more than I accounted for. So you were right.

And if I may suggest - why not post the ported module on backdrop-contrib? That will benefit the community.