D7 small survey: listing of node types at /node/add
Hello, I was wondering: Hasn't anyone ever felt bothered by the complete listing of the available node types at /node/add (where the user has create permission)? I am the only one who sometimes wishes there were a way to NOT list some node type on this list, even though the user has the proper permission? Here is a simple scenario. We have a Problem node type and a Solution node type, in a way that each Solution is attached to a corresponding Problem. The user can create both Problems and Solutions, but the Solution are best created when following a link from the Problem node, so that we can customize the link thus: /node/add/solution?problem_id=123 Now if the user goes to /node/add and from there to /node/add/solution there is no problem_id defined. Obviously, there are many different workarounds, e.g. by creating an intermediary form to select the parent node. But I run into this problem often and all my workarounds feel like hacks and I am getting tired of them. What do you think? Would it be a useful feature for D7 to modify the second half of the function node_add() so that the listing can be customized? Or am I doing something wrong, or I am the only one facing this problem? thanks, Augustin.
On Dec 5, 2007 1:46 PM, Augustin (Beginner) <drupal.beginner@wechange.org> wrote:
Obviously, there are many different workarounds, e.g. by creating an intermediary form to select the parent node. But I run into this problem often and all my workarounds feel like hacks and I am getting tired of them.
What do you think? Would it be a useful feature for D7 to modify the second half of the function node_add() so that the listing can be customized?
Both Drupal 5 and to my knowledge Drupal 6 has the ability to overwrite the registered handler functions for paths you wish to override. So you can do your own listing or whatever shiny page content you'd like to display. Gabor
On Wednesday 05 December 2007 20:41, Gábor Hojtsy wrote:
Both Drupal 5 and to my knowledge Drupal 6 has the ability to overwrite the registered handler functions for paths you wish to override. So you can do your own listing or whatever shiny page content you'd like to display.
I just tried. It's so simple this way!! I never thought about using hook_menu() this way. I knew that what I was doing were dirty hacks. :-/ Thanks a lot, Gábor. :) Augustin.
I'd love to be able to do this. I currently get around it by not putting the link on the menu and assuming the users don't know Drupal to go there directly. A better way would be great. Unfortunately, what Gábor wrote is greek to me. Do you have time to explain this in a bit more detail? Off list, if you don't want to clutter the list. Thanks, Michelle PS: I think it's tie to change your nick name. ;) ----- Original Message ----- From: "Augustin (Beginner)" <drupal.beginner@wechange.org> To: <development@drupal.org> Sent: Wednesday, December 05, 2007 7:17 AM Subject: Re: [development] D7 small survey: listing of node types at/node/add On Wednesday 05 December 2007 20:41, Gábor Hojtsy wrote:
Both Drupal 5 and to my knowledge Drupal 6 has the ability to overwrite the registered handler functions for paths you wish to override. So you can do your own listing or whatever shiny page content you'd like to display.
I just tried. It's so simple this way!! I never thought about using hook_menu() this way. I knew that what I was doing were dirty hacks. :-/ Thanks a lot, Gábor. :) Augustin.
Well, thinking a bit more about it, I think: 1) that Gábor 's hint is easy and very useful for D6, and simpler than what I sometimes had to do. I'll use that for now. 2) that there should be an even easier, more drupalish solution for D7. Here is the issue which includes 2 very simple proposals consistent with the rest of Drupal: http://drupal.org/node/198059 On Wednesday 05 December 2007 21:59, Michelle Cox wrote:
Unfortunately, what Gábor wrote is greek to me. Do you have time to explain this in a bit more detail?
In hook_menu(), create an item that maps node/add to your own function callback: $items[] = array('path' => 'node/add', 'title' => t('Create content'), 'callback' => 'mymodule_node_add', // -->> check this line. 'access' => user_access('access content'), 'type' => MENU_ITEM_GROUPING, 'weight' => 1); This will override the core callback for node/add. copy the function node_add() into a new function mymodule_node_add() which you can then customize anyway you want. At least, that's what I understood Gabor's comment to mean. It's simple and much more flexible than what I did before, but I don't like having to copy a whole core function just to remove one item. Here is a better way for D7: http://drupal.org/node/198059
PS: I think it's tie to change your nick name.
That's very kind, but I still think it would be a bit premature... ;) I often look in awe at what many other members in this list accomplish regularly without breaking a sweat! Blessings, Augustin.
----- Original Message ----- From: "Augustin (Beginner)" <drupal.beginner@wechange.org> To: <development@drupal.org> Sent: Wednesday, December 05, 2007 8:39 AM Subject: [development] link to issue + solution Re: D7 small survey: listingof node types at/node/add
1) that Gábor 's hint is easy and very useful for D6, and simpler than what I sometimes had to do. I'll use that for now.
Will it work in D5? D6 is a distant dream for me, unfortuantely.
2) that there should be an even easier, more drupalish solution for D7.
That's even more distant. :) [In hook_menu(), create an item that maps node/add to your own function callback: $items[] = array('path' => 'node/add', 'title' => t('Create content'), 'callback' => 'mymodule_node_add', // -->> check this line. 'access' => user_access('access content'), 'type' => MENU_ITEM_GROUPING, 'weight' => 1); This will override the core callback for node/add. copy the function node_add() into a new function mymodule_node_add() which you can then customize anyway you want. At least, that's what I understood Gabor's comment to mean. It's simple and much more flexible than what I did before, but I don't like having to copy a whole core function just to remove one item.] I think I get this. Will have to digest it a bit. [That's very kind, but I still think it would be a bit premature... ;) I often look in awe at what many other members in this list accomplish regularly without breaking a sweat! ] Well, you're more advanced than me and I've been at this 2.5 years. :) Michelle
Augustin - it is misleading to include 'access' and friends in your menu item. They will *NOT* be used. Anyone who relies on them has unknowingly compromised their security. You can only inherit whatever the original menu item had in 'access'. I think this is clearer:
$items[] = array('path' => 'node/add', 'callback' => 'mymodule_node_add', // -->> check this line. );
On Dec 5, 2007, at 9:39 AM, Augustin (Beginner) wrote:
Well, thinking a bit more about it, I think:
1) that Gábor 's hint is easy and very useful for D6, and simpler than what I sometimes had to do. I'll use that for now.
2) that there should be an even easier, more drupalish solution for D7.
Here is the issue which includes 2 very simple proposals consistent with the rest of Drupal: http://drupal.org/node/198059
On Wednesday 05 December 2007 21:59, Michelle Cox wrote:
Unfortunately, what Gábor wrote is greek to me. Do you have time to explain this in a bit more detail?
In hook_menu(), create an item that maps node/add to your own function callback:
$items[] = array('path' => 'node/add', 'title' => t('Create content'), 'callback' => 'mymodule_node_add', // -->> check this line. 'access' => user_access('access content'), 'type' => MENU_ITEM_GROUPING, 'weight' => 1);
This will override the core callback for node/add.
copy the function node_add() into a new function mymodule_node_add() which you can then customize anyway you want.
At least, that's what I understood Gabor's comment to mean.
It's simple and much more flexible than what I did before, but I don't like having to copy a whole core function just to remove one item.
Here is a better way for D7: http://drupal.org/node/198059
PS: I think it's tie to change your nick name.
That's very kind, but I still think it would be a bit premature... ;) I often look in awe at what many other members in this list accomplish regularly without breaking a sweat!
Blessings,
Augustin.
One caveat - in drupal5 you can only override the callback function. any changes to 'access' will be silently ignored. this form of altering is not supported in d5. it is supported in d6 wth hook_menu_alter() On Dec 5, 2007, at 7:41 AM, Gábor Hojtsy wrote:
On Dec 5, 2007 1:46 PM, Augustin (Beginner) <drupal.beginner@wechange.org> wrote:
Obviously, there are many different workarounds, e.g. by creating an intermediary form to select the parent node. But I run into this problem often and all my workarounds feel like hacks and I am getting tired of them.
What do you think? Would it be a useful feature for D7 to modify the second half of the function node_add() so that the listing can be customized?
Both Drupal 5 and to my knowledge Drupal 6 has the ability to overwrite the registered handler functions for paths you wish to override. So you can do your own listing or whatever shiny page content you'd like to display.
Gabor
One caveat - in drupal5 you can only override the callback function. any changes to 'access' will be silently ignored. this form of altering is not supported in d5. it is supported in d6 wth hook_menu_alter()
Right and let draw attention to this: people were doing terrible hacks to alter the menu, now you can easily with hook_menu_alter , one of the sweet features of the new system.
Quoting "Augustin (Beginner)" <drupal.beginner@wechange.org>:
Here is a simple scenario. We have a Problem node type and a Solution node type, in a way that each Solution is attached to a corresponding Problem. The user can create both Problems and Solutions, but the Solution are best created when following a link from the Problem node, so that we can customize the link thus: /node/add/solution?problem_id=123
Now if the user goes to /node/add and from there to /node/add/solution there is no problem_id defined.
Obviously, there are many different workarounds, e.g. by creating an intermediary form to select the parent node. But I run into this problem often and all my workarounds feel like hacks and I am getting tired of them.
Node Relativity can create problem/solution types where you have a node that you want to attach children to. The child creation menu item is on the viewing page if the user has the rights to create the node type. Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
I have a similar need for the NodeReview module, and solved it using weird permission handling as well. Specifically, hook_access() for the node type returns false for create permissions if on the node/add page. That works for everyone except uid 1. Have a look at the code if you're interested. I talked with chx in Sunnyvale about a nicer way of doing it in Drupal 6, and we determined that hook_menu_alter() was The Solution(tm). --Larry Garfield On Wed, 5 Dec 2007 20:46:49 +0800, "Augustin (Beginner)" <drupal.beginner@wechange.org> wrote:
Hello,
I was wondering: Hasn't anyone ever felt bothered by the complete listing of the available node types at /node/add (where the user has create permission)?
I am the only one who sometimes wishes there were a way to NOT list some node type on this list, even though the user has the proper permission?
Here is a simple scenario. We have a Problem node type and a Solution node type, in a way that each Solution is attached to a corresponding Problem. The user can create both Problems and Solutions, but the Solution are best created when following a link from the Problem node, so that we can customize the link thus: /node/add/solution?problem_id=123
Now if the user goes to /node/add and from there to /node/add/solution there is no problem_id defined.
Obviously, there are many different workarounds, e.g. by creating an intermediary form to select the parent node. But I run into this problem often and all my workarounds feel like hacks and I am getting tired of them.
What do you think? Would it be a useful feature for D7 to modify the second half of the function node_add() so that the listing can be customized?
Or am I doing something wrong, or I am the only one facing this problem?
thanks,
Augustin.
participants (7)
-
Augustin (Beginner) -
Earnie Boyd -
Gábor Hojtsy -
Karoly Negyesi -
Larry Garfield -
Michelle Cox -
Moshe Weitzman