Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that hook_control is likely to be a better name for the system. Thoughts are welcome. MVC flames are not. Regards NK
To be honoust I prefer hook_link(), which did little of what we have now in the drupal 2/3 era.. But still, what ever we do with hook_menu() we _are_ always generating links, right? Stefan Op 12-dec-2006, om 12:33 heeft Zohar Stolar het volgende geschreven:
It's true, but hook_menu is, after all, dealing with paths and links. Paths and links are what allows us to navigate inside a site, and they are commonly combined in a menu. If we checked it statistically, I'm sure we would have found that most of the items in the menu hook are not actually visible as menu items, but when thinking of a menu i a larger context, we find it's not at all a bad name. A menu is a representation of a site's structure, whether it's a logical structure, or a more physic one. So in this way - even if an item is not visible, it's still part of the structure, and as a result - has its place in the menu.
Zohar
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
hook_control
is likely to be a better name for the system. Thoughts are welcome. MVC flames are not.
Regards
NK
But still, what ever we do with hook_menu() we _are_ always generating
MENU_CALLBACK? I don't think we're generating links. I think we're generating URLs. I don't like hook_control. Far too generic. hook_router maybe. -- Morbus Iff ( death to videodrome long live the new flesh ) Technical: http://www.oreillynet.com/pub/au/779 Culture: http://www.disobey.com/ and http://www.gamegrene.com/ icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
On 12/12/06, Morbus Iff <morbus@disobey.com> wrote:
I don't like hook_control. Far too generic. hook_router maybe.
I was thinking along similar lines: hook_route would be good IMO. "Routes" or "Routing" is the name of the Ruby On Rails equivalent of the "Drupal menu system". This would also be fitting, because Karoly's proposed improvements for 6.x will make the menu system more like RoR's routing system. Another possibility is hook_map or hook_mapping - since the job of the menu system is essentially to map URLs to callback functions. Then again, do we really need to rename hook_menu? Developers are very familiar with the current semantics, and a name change will cause more than a bit of confusion. I also think that hook_menu is about as good a name as any other. Cheers, Jaza.
I agree that hook_menu() is better off renamed. This hook is the core of Drupal, and old timers know what it is. For new comers, it is not obvious why it is called menu. hook_router() seems like the best choice so far, the menu items "route" requests to different functions.
I'm not sure whether this is up for vote or not, but if so, -1 from me. From one version of drupal to the next, there are far too many things that break modules. I get frustrated when I have to change my modules for a change like this (merely semantic). If however it is already decided to change the name, I suggest hook_path(). Each item returned does define a path, does it not? -Dave
Khalid B wrote:
I agree that hook_menu() is better off renamed.
This hook is the core of Drupal, and old timers know what it is. For new comers, it is not obvious why it is called menu.
hook_router() seems like the best choice so far, the menu items "route" requests to different functions. As a relative newcomer, "route" is worse than "menu." Route is too tied into to network usage, bringing to mind something that redirects URLs instead of registering available functions. I prefer the "dispatch" suggestion, but think "register" is even better - but then that's coming from a familiarity with dependency injection, where "register" is common usage.
But again, as a relative newcomer, I had no trouble with the concepts around hook_menu, and my bottom line opinion is to leave it alone. The introduction in menu.inc accomplishes the job. I think it would be more useful to have a middle level view of Drupal processing, something in between the handbook page "Introduction to Drupal modules" page and the three "Drupal's * serving|building mechanism" pages. Gary
On Tue, 12 Dec 2006, Morbus Iff wrote:
But still, what ever we do with hook_menu() we _are_ always generating
MENU_CALLBACK?
I don't think we're generating links. I think we're generating URLs.
I don't like hook_control. Far too generic. hook_router maybe.
I called this URL registry component in my small OO based PHP CMS (developed a few years go) the "router". This was implemented in Class Router. I am not sure though that the menu hook should be renamed at all. Gabor
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
hook_control
I don't are much about names of funtions and I don't like to rename funtions just for the sake of renaming them. Maybe the improved menu patch should hit 6.x first before we discuss renaming this one. Cheers, Gerhard
On 12/12/06, Karoly Negyesi <karoly@negyesi.net> wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
hook_control
is likely to be a better name for the system. Thoughts are welcome. MVC flames are not.
I've actually thought for some time that the hook should be named: hook_dispatch ...which better represents its true purpose in life: providing the information based on which the request is dispatched to the appropriate callback in the module. -- Arto Bendiken | arto.bendiken@gmail.com | http://bendiken.net/
On 13/12/06, Arto Bendiken <arto.bendiken@gmail.com> wrote:
I've actually thought for some time that the hook should be named:
hook_dispatch
...which better represents its true purpose in life: providing the information based on which the request is dispatched to the appropriate callback in the module.
While I'm OK with hook_menu staying in place, if it was to be renamed hook_dispatch sounds like a good option to me. -- Cheers Anton (aka styro@drupal.org)
On Tue, 2006-12-12 at 11:57 +0100, Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
hook_control
is likely to be a better name for the system. Thoughts are welcome. MVC flames are not.
Regards
NK
I'm pretty comfortable with menu as it stands. Unless we actually decouple it from the menu system completely, I think the name is appropriate. The fact that out menu items are built out of our URL<->callback registry is kind of nice. I think how some of the types are handled is a little confusing. I don't think we should have any locked menu items. Its convenient that we don't have to define these in two places or merge the callback/router/whatchamacallit data into the available menu item data. plus we already know what drupalites call their whatchamacallit. -- Anarchists for Bush 2008 Why change horsemen in the middle of an apocalypse?
I'm fine with hook_menu(). You can still define menu items in that hook and any change would cause more trouble than it's worth IMO. Rob Roy Barreca Founder and COO Electronic Insight Corporation http://www.electronicinsight.com rob@electronicinsight.com Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
hook_control
is likely to be a better name for the system. Thoughts are welcome. MVC flames are not.
Regards
NK
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well. I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are. -mf
Michael Favia wrote:
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well.
I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are. -mf
I like hook_path, hook_path_register or hook_entry (because it's really a main entry point registry).
ok, i think karoly has enough feedback on this drupal 6 feature. lets refocus on the drupal 5 issues queues as requested by dries.
On 12 Dec 2006, at 22:19, Michael Favia wrote:
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well.
I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are.
Great feedback, Michael. I know a few people that told me the exact same story. Karoly senses this as well -- otherwise he would not have made the suggestion. It's a real problem and I think we should fix it. Renaming hook_menu() causes some pain, but in the long term, it will pay off. As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements. Like it or not, but your menu code is going to break anyway. Thus, I'm in favor of renaming hook_menu() to hook_router() as that is semantically more accurate and matches the terminology used in other systems (eg. RoR and PEAR). I'd be happy to debate and weigh alternative names but let's not invent new terminology for an existing pattern. Let's go with hook_router() for now, or come up with a list of names that other systems use. Thanks, -- Dries Buytaert :: http://www.buytaert.net/
I was similarly confused about hook_menu's name the first time, like Michael. But I also agree with Gerhard (killes) that gratuitous name changes should be avoided (although I propose to rename all plural database table names to the singular). Given that, I think that hook_dispatch() by far best captures what the hook really does. It's really a jump table or dispatch table that one ends up coding in the implementation, anyway. I'm afraid hook_router does not sound right to me. Router has too many other possibilities in English and in computer technology terminology. Router is too "squishy" and vague. Dispatch nails it right on the head. IHMO, of course. ..chrisxj
On 13-Dec-06, at 2:43 AM, Dries Buytaert wrote:
On 12 Dec 2006, at 22:19, Michael Favia wrote:
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well.
I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are.
Great feedback, Michael. I know a few people that told me the exact same story. Karoly senses this as well -- otherwise he would not have made the suggestion. It's a real problem and I think we should fix it.
Renaming hook_menu() causes some pain, but in the long term, it will pay off. As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements. Like it or not, but your menu code is going to break anyway.
Thus, I'm in favor of renaming hook_menu() to hook_router() as that is semantically more accurate and matches the terminology used in other systems (eg. RoR and PEAR).
I'd be happy to debate and weigh alternative names but let's not invent new terminology for an existing pattern. Let's go with hook_router() for now, or come up with a list of names that other systems use.
Sure, I'll throw in my $0.02... wth. I think that with a rewrite of menu (that chx has underway already), it makes it an ok time to switch the naming around. I agree it's gonna break anyway, let's get it right. I'm ok with hook_router, although in my experience hook_dispatch might be more MVC "true" - certainly in the Java world. I can put a +1 behind either hook_router or hook_dispatch though. -- James Walker :: http://walkah.net/ :: xmpp:walkah@walkah.net
unsubscribe -----Original Message----- From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of James Walker Sent: Wednesday, December 13, 2006 9:56 AM To: development@drupal.org Subject: Re: [development] Rename hook_menu ? On 13-Dec-06, at 2:43 AM, Dries Buytaert wrote:
On 12 Dec 2006, at 22:19, Michael Favia wrote:
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well.
I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are.
Great feedback, Michael. I know a few people that told me the exact same story. Karoly senses this as well -- otherwise he would not have made the suggestion. It's a real problem and I think we should fix it.
Renaming hook_menu() causes some pain, but in the long term, it will pay off. As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements. Like it or not, but your menu code is going to break anyway.
Thus, I'm in favor of renaming hook_menu() to hook_router() as that is semantically more accurate and matches the terminology used in other systems (eg. RoR and PEAR).
I'd be happy to debate and weigh alternative names but let's not invent new terminology for an existing pattern. Let's go with hook_router() for now, or come up with a list of names that other systems use.
Sure, I'll throw in my $0.02... wth. I think that with a rewrite of menu (that chx has underway already), it makes it an ok time to switch the naming around. I agree it's gonna break anyway, let's get it right. I'm ok with hook_router, although in my experience hook_dispatch might be more MVC "true" - certainly in the Java world. I can put a +1 behind either hook_router or hook_dispatch though. -- James Walker :: http://walkah.net/ :: xmpp:walkah@walkah.net
As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements. I wasn't thinking about this, but if there is going be an overhaul, I agree that a name change is no big deal.
So hook_router() gets my vote as hook_dispatch() is a bit confusing to me and I assume the less-technical developers feel the same about dispatch (I have no idea what a dispatch table or jump table is). Rob Roy Barreca Founder and COO Electronic Insight Corporation http://www.electronicinsight.com rob@electronicinsight.com Dries Buytaert wrote:
On 12 Dec 2006, at 22:19, Michael Favia wrote:
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
I was initially confused by this and underestimated the hooks importance and functionality. At first i thought the name wasn't as important as it's proper documentation as a pillar of the drupal system. But after a moment of reflection, I remember being confused by this on my first time through as well.
I'm not saying the documentation isn't there I'm just relating that i didn't find it by default like I found FAPI and the other hooks intuitive, etc probably because it was called a Menu system and I discounted it as what i was looking for. Anything more descriptive sounds good to me. Control, route, path, etc. I hope I would have noticed any of those for what they are.
Great feedback, Michael. I know a few people that told me the exact same story. Karoly senses this as well -- otherwise he would not have made the suggestion. It's a real problem and I think we should fix it.
Renaming hook_menu() causes some pain, but in the long term, it will pay off. As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements. Like it or not, but your menu code is going to break anyway.
Thus, I'm in favor of renaming hook_menu() to hook_router() as that is semantically more accurate and matches the terminology used in other systems (eg. RoR and PEAR).
I'd be happy to debate and weigh alternative names but let's not invent new terminology for an existing pattern. Let's go with hook_router() for now, or come up with a list of names that other systems use.
Thanks,
-- Dries Buytaert :: http://www.buytaert.net/
Rob Barreca wrote:
As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements.
So hook_router() gets my vote as hook_dispatch() is a bit confusing to me and I assume the less-technical developers feel the same about dispatch (I have no idea what a dispatch table or jump table is).
Naturally I prefer dispatch to router =)
Naturally I prefer dispatch to router =) Rightly so, I think Views escapes the "less-technical" category. ;-)
But seriously, even though I'm just beating a dead horse here (what else are mailing lists for), I really don't care which way this goes. Rob Roy Barreca Founder and COO Electronic Insight Corporation http://www.electronicinsight.com rob@electronicinsight.com Earl Miles wrote:
Rob Barreca wrote:
As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements.
So hook_router() gets my vote as hook_dispatch() is a bit confusing to me and I assume the less-technical developers feel the same about dispatch (I have no idea what a dispatch table or jump table is).
Naturally I prefer dispatch to router =)
The first sentence of http://api.drupal.org/api/HEAD/group/menu : "Define the navigation menus, and route page requests to code based on URLs." -1 for changing the menu hook at all (+1 for improving it). -1 for gratuitous API changes, even when precedented by ROR terminology.
On Wednesday 13 December 2006 12:24, Earl Miles wrote:
Rob Barreca wrote:
As we are going to completely overhaul the menu system in Drupal 6, this is the right time to make semantic improvements.
So hook_router() gets my vote as hook_dispatch() is a bit confusing to me and I assume the less-technical developers feel the same about dispatch (I have no idea what a dispatch table or jump table is).
Naturally I prefer dispatch to router =)
Personally I prefer dispatch. To me "router" is a networking device. This is a function dispatcher. To "less technical" people, both terms are meaningless. :-) I find dispatch to be more descriptive. -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Karoly Negyesi wrote:
Today it was raised in #drupal that hook_menu has so little to do with menus nowadays that
http://api.drupal.org/api/HEAD/file/includes/menu.inc The menu system deals with all sorts of different - ummm - menus and menu properties. Take a look at the constants we have defined. In the menu system menus aren't really menus is in the cases where they are callbacks - that don't necessarily have a 'menu' item - i.e. what code gets fired off when something requests q=x (but not necessarily when a user clicks on a 'menu'). But this is more about the 'menu object' - and not about the hook that generates it. I've long thought that 'menu object' was misnamed - but as a whole when looking at the code a great deal of the menu system is really about menus. What do we do when people ask "how do I get my module to add a menu item to the navigation menu?" or "how do I create a tabbed menu at the top of my module's landing page?" Answer "write code that uses hook_dispatch/control/route"??? Not sure that makes sense. But for all other reasons I'm for a name change. I'm so torn. andre
participants (24)
-
Andre Molnar -
Anton -
Arto Bendiken -
Chris Johnson -
Darrel O'Pry -
Dave Cohen -
Dries Buytaert -
Earl Miles -
Gabor Hojtsy -
Gary Feldman -
Geoff Staples -
Gerhard Killesreiter -
James Walker -
Jeremy Epstein -
John VanDyk -
Karoly Negyesi -
Khalid B -
Larry Garfield -
Michael Favia -
Morbus Iff -
Moshe Weitzman -
Rob Barreca -
Stefan Nagtegaal -
Zohar Stolar