Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By lishevita on
I'm developing a module for Drupal 6.x that has its own content type. This content type should never ever ever be part of a book, so I don't want "Book Outline" to show up in the create content page at all.
Is there a code-y way to make that block disappear from this content type entirely?
Comments
...
'Book' comes with a settings page that lets the admin select which content-types are allowed in a book. These are stored in the 'book_allowed_types' variable. So in you hook_install append your content-type to this list.
Or, if the name of your content-type is dynamic, imlemenet hook_form_alter and put an
'#access' => FALSE
on the Outline box. To get rid of the 'Outline' tab, implement hook_menu_alter.OK, after reading moofie's
OK, after reading moofie's reply, I found http://groups.drupal.org/node/4308 which was helpful.
Now how do I find out what the name of the Outline tab is? I've been looking at the source to try to guess at it. This does not work:
function fring_addon_form_alter() {
if($form_id == "edit-fring-addon-node-form") {
$form['edit-book-bid'] = array( //this is the piece that I don't know how to find the right name for!!!
'#access' => 'false',
);
}
}
...
We have two things to get rid of: the Outline box, and the Outline tab.
To get rid of the Outline box, which is shown in a form, we use hook_form_alter:
(Change 'mymodule' to the name of your module. And 'story' to your special node-type(s).)
Now we have to get rid of the Outline tab.
The outline tab is 'node/%node/outline' (we learn this by a cursory look at book's source code). That's a menu item. We want to modify this menu item so that it doens't show on 'story' nodes. We do this modification in hook_alter_menu:
(Again, change 'mymodule' and 'story'...)
A note about hook_menu_alter: Drupal caches the menu, so this hook is called only when Drupal rebuilds the menu. To trigger this rebuilding you'll have to clear Drupal's cache. This is done automatically when installing a module, but you'll have to do this manually now (tip: the 'Devel' module provides a 'clear cache' command). You should see a "I'm modifying the.." message once.
Thanks for the code I made it
Thanks for the code I made it a small module with code similar to above :), I guess you should add some settings and contribute the module.
Nobookoutline Module
I coded a small module with some parts of your code:here - it has a configuration page to select which node types to show the book outline form and menu for. Hope it helps.