per node type settings available?
druppi - March 27, 2009 - 17:21
| Project: | BookMadeSimple |
| Version: | 6.x-1.5 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | MarcElbichon |
| Status: | closed |
Description
I am searching for a module that improves drupal's built-in book handling in the following way:
- define the possible types of child pages on a per node type base (I've found the outline module, but this does this on a per node basis, much too fine for me).
- define the possible types of parent pages on a per node type base (it's the same as above, but from a different point of view)
- select the node type when creating a child page (BMS does this very well)
What do I need this for?
I am planning to create a site with primary links linking to pages listing all nodes of a certain type (about us: different books for different groups, photo albums: different books containing images only, and so on). So a photoalbum can hold images only, a about-us-node can hold pages only). The advantage is that the editors must not know drupal's menu system, but the "menu structure" is created automatically.
It would be great, if this was possible with BMS!

#1
This is a good suggestion.
Try to do this but i'm very busy at this time so i don't know when i can do this.
If somebody wants to work on it .............
#2
Hi,
Can you test this version ?
Rename the file to book_made_simple.module and copy it in the module directory.
In the content type form, in BookMadeSimple section, i added two lists. One for content-types allowed for this content type and another for content-type allowing this one.
This selection will overwrite content types list of the BMS settings. If no selection has been found for a content-type, those selected in BMS settings will be shown.
Are you OK with this ?
Could you test for me ?
Be careful. For a content-type, if you allow the same content-type as child, don't forget to add it too in the allowing content-type list.
#3
Yeah, this works fine!
But some hints and suggestions:
#4
In your template.php, create this function :
<?php
// First argument is array of allowed content types
// Second argument is the node
function yourtheme_add_child_book_content_types($allowedTypes, &$node) {
$html = "<ul>";
foreach ($allowedTypes as $type => $name ) {
$isCleanUrl = variable_get('clean_url', 0);
$newUrl = base_path() . "node/add/" . str_replace('_', '-',$type) . "/parent/" . $node->nid;
if (! $isCleanUrl) {
$newUrl = base_path() . "?q=node/add/" . str_replace('_', '-',$type) . "/parent/" . $node->nid;
}
$html .= "<li><a href='" . $newUrl . "'>" . $name ."</a></li>";}
return $html . "</ul>";
}
?>
Could you test this new version ?
#5
A little correction pour FireFox
#6
ad 1) That might be the case. But if you do not use an own theme? Create one to implement this function? And what does theming have to do with BMS?
ad 6: I mean something like this:
<?php$isCleanUrl = variable_get('clean_url', 0);
if (user_access('administer book outlines')) {
if ($isCleanUrl) {
$newUrl = "";
} else {
$newUrl = "?q=";
}
$html = "<a href=\"" . base_path() . $newUrl . "admin/content/book/" . $node->book["bid"] . "\"> " . t("Rearrange") . "</a> ";
} else {
$html = "";
}
?>
Sorry, but I am not a php programmer.
#7
Ok, looks much better with checkboxes ;)
But what does "Allow content type as child of default book." mean? Either I can select this node type as child of "book" or not. I know, you need "book" for your "Add child page" selection box, as it needs at least two entries to work correctly. And the first entry "Add child page" always links to "book".
Another caveat with this selection box:
How do you want to explain this behavior to normal users? And, as I wrote earlier, you should not rely on javascript where not necessary. Either provide a javascript and a link version or a link-only version.
What about this:
<?php$html .= t("Add child page") . ": <ul>";
foreach ($allowedTypes as $type => $name ) {
$typename = str_replace('_', '-',$type);
$html .= "<li class=\"book_made_simple_" . $typename . "\"><a href=\"";
if ($isCleanUrl) {
$newUrl = base_path() . "node/add/" . $typename . "?parent=" . $node->book["mlid"];
} else {
$newUrl = base_path() . "?q=node/add/" . $typename . "&parent=" . $node->book["mlid"];
}
$html .= $newUrl . "\">" . t($typename) . "</a></li>";
}
return $html . "</ul>";
}
?>
(This was a modification of your released module)
#8
Allow content type as child of default book is for compatibility.
In BMS settings, you can select content-type to add to book. This will be default values for content-type with no child defined.
This means that this content-type will be allowed for all content-type (even new content-type) without have to add it in form setting.
To modify selection,you must theme the function. See theming with Drupal for more informations
#9
Added to release 2.0
#10
I have had a quick look at that new release available at your google page. You seem to have added some nice features. But your code is not clean enough to provide an other release than a dev release!
I will also encourage you to find a way to solve your problem with the firewall as you break the update status for your module! Also issues for your module can not be filed with the correct version number on drupal.org. Perhaps you can ask someone else to do this job for you?
Nevertheless, you did a great job! In my opinion, this job should have been done by the developers of the book module themselves!
#11
I'm completly agree with you for the last remark of you post (lol) !!!!
#1 - Changed tabs to chars
#2 - Corrected
#3 - Corrected. Added t() function to values of dropdown listbox
#4 - I'd like but Drupal don't want to open 2403 port. Would you want to publish code for me ?
#12
Sorry, I can't help you in publishing the code. I have currently no experience in that manner. Please ask someone else :(
This applies to your other modules, too.