Posted by simonvwade on May 13, 2009 at 2:34pm
Jump to:
| Project: | Submenu Tree |
| Version: | 6.x-1.4 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
// Inject some sane defaults
if (empty($node->submenutree_enable)) {
$node->submenutree_enable = 0;
- $node->submenutree_display = SUBMENUTREE_DISPLAY_MENU;
+ if( !$node->submenutree_display ) {
+ $node->submenutree_display = SUBMENUTREE_DISPLAY_MENU;
+ }
$node->submenutree_weight = 1;
}
if (empty($node->siblingmenutree_enable)) {
$node->siblingmenutree_enable = 0;
- $node->siblingmenutree_display = SUBMENUTREE_DISPLAY_MENU;
+ if( !$node->siblingmenutree_display ) {
+ $node->siblingmenutree_display = SUBMENUTREE_DISPLAY_MENU;
+ }
$node->siblingmenutree_weight = 1;
}
Comments
#1
This means that developers can do the following:
function hook_form_alter(&$form, $form_state, $form_id) {
if( strpos($form_id, 'node_form') > 0 ) {
$node = $form['#node'];
if( !$node->siblingmenutree_enable ) {
$node->submenutree_display = SUBMENUTREE_DISPLAY_BLOCK_MENU;
}
if( !$node->submenutree_enable ) {
$node->submenutree_display = SUBMENUTREE_DISPLAY_BLOCK_MENU;
}
}
}
#2
Hi,
I suspect I understand what you're trying to achieve, but I'm not absolutely certain. To prevent possible confusion, can you please explain it to me? There may be an easier way to do this.
Also, please don't supply 'patches' like that. Please generate a patch file and attach it. It's a bit more work, but less error prone.
#3
I think that he wants an easy way to set the defaults somewhere else; maybe this is a bit cleaner.
<?php
// Inject some sane defaults
$defaults = array(
'submenutree_enable' => 0,
'submenutree_display' => SUBMENUTREE_DISPLAY_MENU,
'submenutree_weight ' => 1,
'siblingmenutree_enable' => 0,
'siblingmenutree_display' => SUBMENUTREE_DISPLAY_MENU,
'siblingmenutree_weight' => 1);
foreach ($defaults as $property => $default) {
$node->$property = isset($node->$property) ? $node->$property: $default;
}
?>
Maybe extend the scope of this request to have default settings per content type or globally?
I achived a similar thing by using th nodeapi hook, but I wanted this enabled by default, not disabled with a non-standard default display.
<?php
/**
* Implementation of hook_nodeapi().
*/
function HOOK_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'prepare') {
if (!$node->nid)) {
// I used $node->type in a switch to toggle the action
$node->submenutree_enable = 1;
$node->submenutree_display = SUBMENUTREE_DISPLAY_TEASERS;
$node->submenutree_weight = 1;
}
}
}
?>
And having an option to set all default values on all content types with one click would be gold (currently developing another site with 15+ content types - it is a drag editing 15 pages to turn on the new features....)
Cheers
#4
@3: Your suggestion is clear enough to understand and I have more to say on it below. The original post was a bit ambiguous and since the author didn't follow up, I didn't have sufficient information to go any further.
Now, your idea ...
Sounds decent. I'd suggest configuration should almost certainly be per content type.
However, it's a non-trivial chunk of functionality (requiring a new admin page or two) and it's not something I really have the time for. If you'd like to follow this up, please be welcome to contribute a patch.
#5
Subscribing, just letting know I would love this feature as well!
Thanks for the hook_nodeapi snippet. This was absolutely necessary for me to be able to do what I'm planning to do! :)
#6
Expiring this issue since it is very old and I'm not sure if it is still applicable.