I am submitting a patch for node.module to use Forms API to display the default welcome message that users see upon install, before publishing content.
This is a follow up to http://drupal.org/node/18340
This is hopefully a better solution than the code found at http://groups.drupal.org/node/2828 under 'Custom welcome message.' I don't like duplicating functions found in core in contrib modules.
This would be useful for install profiles that wish to add to or update the welcome message with additional info. Of course it would require a helper module with the install profile.
Although you may not notice after patching, when compared with the pre patched version, the formatting is very slightly off. I believe the indent for the order list is not as great with this patch, and slightly more text per line fits in the ordered list. I'm not a themeing person, and I'm not sure it's enough to matter, if requested I could post screenshots.
Comment | File | Size | Author |
---|---|---|---|
#83 | 126221-theme_node_default_page.patch | 2.13 KB | snufkin |
#71 | default.patch | 2.29 KB | catch |
#53 | remove_node_frontpage_04.patch | 12.93 KB | Xano |
#43 | node_page_default_43.patch | 5.74 KB | mikey_p |
#35 | node_page_default_35.patch | 8.49 KB | mikey_p |
Comments
Comment #1
chx CreditAttribution: chx commented+ return($form); lose () and also lose drupal_get_form, just call the function and call drupal_render on it. This is not a form.
Comment #2
eaton CreditAttribution: eaton commentedAgreed, this is a perfect use of the general Drupal Rendering API. I'd perfer that we use a properly nested structure, and a theme function, rather than the prefix and suffix elements. I'll roll a version of this later today if possible. As chx said, it's not really a form and there's no need to call it that.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedWouldn't a theme function be better than a form alter?
Comment #4
dmitrig01 CreditAttribution: dmitrig01 commentedThis can be really useful in install profiles.
Comment #5
mikey_p CreditAttribution: mikey_p commentedWell here's a second go around. Added function theme_default_message and removed prefix and suffix stuff from the structured array.
Comment #6
mikey_p CreditAttribution: mikey_p commentedI fixed the description, and fixed a comment in the code, as well as a typo.
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedWithout actually using drupal_get_form (or the equivalent render function), form_alter can't be used hwich is the only reason to use the form system for this output.
I'm not sure the form system is necessary. Is there any reason not to just move the entire thing into the theme function?
I do realize that modules should be able to modify this, so perhaps we need to actually use drupal_get_form and use the form theme function instead, allowing the best of both worlds (modules adding information here; sites completely overriding it with whatever).
Comment #8
eaton CreditAttribution: eaton commentedOr, alternately, we can use the drupal_alter() system proposed in http://drupal.org/node/110888 ... Unifying our structured rendering using FAPI-style arrays, and giving other modules ways to alter thee process, shouldn't force things into using forms when it doesn't make sense.
Comment #9
mikey_p CreditAttribution: mikey_p commented@ merlin in #3 and #7
I've thought more about this, (keeping MVC concepts in mind) and I think the point of this patch is not themeing, but to allow modules to hook into the default message. I'm still not understanding the hook_foo_alter patch well enough to know what I should call this.
@ eaton in #8
I looked at this patch, and I still don't know what else to define this as, it's not a node, not a block, and not a message...Or should it be a message? However there seems to be no allowance for message_alter. I know I've read or heard about hook_message_alter proposals, but maybe that's the best way to go about this, as a message is the best semantic definition of the content that node_page_default provides when no nodes are published. Thoughts?
-Mike
Comment #10
eaton CreditAttribution: eaton commentedI'll reiterate, this isn't a form and I think treating it as such would be a mistake. I still think that a theming solution is a better approach, but a compromise would be to create the structure in a FAPI-style array, then call drupal_alter('welcome_page', $array). That allows modules to implement hook_welcome_page_alter().
Comment #11
mikey_p CreditAttribution: mikey_p commentedI still want to see some simple solution to this problem. I'll try to roll a drupal_alter version of this sometime soon.
I know there are other issues to address this problem (re: sample nodes and such) but until those get settled, I think this would be an elegant way to fix this.
Comment #12
mikey_p CreditAttribution: mikey_p commentedHere's a new version that uses a structured array, drupal_alter, and a theme function. The welcome message can now be altered by modules, or themed with it's own theme function.
Comment #13
floretan CreditAttribution: floretan commentedThe proposed implementation and code look good to me, but I would change 'node_page_default' to 'default_welcome_page' or something similar.
The name theme_node_page_default() is too ambiguous and it doesn't actually represent what this theme function does (at least not to a themer who might not be aware of why this page has anything to do with nodes).
Comment #14
mikey_p CreditAttribution: mikey_p commentedChanged the drupal_alter and theme to 'default_welcome_page'
Comment #15
merlinofchaos CreditAttribution: merlinofchaos commentedNo, the function name 'default_welcome_page' violates namespace rules.
Change it back to node_page_default or maybe node_welcome_page if you like, but it should be either node_* or drupal_* namespace.
Comment #16
floretan CreditAttribution: floretan commented@merlinofchaos, you're definitely right on the namespace rule, and I think that node_welcome_page gets us what we want both in terms of naming conventions and meaningfulness. Same patch as #14, but using "node_welcome_page".
Comment #17
mikey_p CreditAttribution: mikey_p commentedReroll
Comment #18
snufkin CreditAttribution: snufkin commentedPatch still applies, rerolled against head.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedThe last submitted patch failed testing.
Comment #20
dwwSorry, I think this is a bug, not a feature. I just discovered this since someone asked in IRC how to customize this, and when I looked at the code, I was shocked to see raw HTML being generated in node.module. :( I searched and quickly found this issue. If the answer is "to customize, hack core", it's a bug, IMHO, and I'd support backporting to D6 and D5. "Just write your own module to occupy /node" is no excuse for node.module to be generating raw HTML itself...
Comment #21
mikey_p CreditAttribution: mikey_p commentedI don't think the exceptions provided by the test bot are related to this patch, regardless this should probably get some tests to go with it so I'll leave it at CNW.
Comment #22
mikey_p CreditAttribution: mikey_p commentedWell this is one approach. I feel torn over whether to dump this into theming, or leave it with drupal_render. In this patch I did away with the theme function and let drupal_render handle the whole deal. It feels like this is the easiest way to structure the data being passed into drupal_alter, but I fear that themers may be miffed that there is markup not in a theme function, even though it isn't really hardwired.
My concerns with using a theme function to handle the markup of this is that it requires the data being passed into it to be slightly more structured, and if you really want to be able to freely modify the front page, then you're forced into the structure of the theme function.
Thoughts?
Comment #23
mikey_p CreditAttribution: mikey_p commentedDuh, just realized I could specify #theme for drupal_render(). I'll give that a try and then update..
Comment #24
mikey_p CreditAttribution: mikey_p commentedOkay now this should make much more sense, we have a theme function that handles the structured data and turns it into markup using drupal_render, so we can do away with all the html in #prefix/#suffix and just structure it, yet if folks want to do markup on it with drupal_render, and undo the theme function, they certainly could.
Also comes with tests now and a mock module.
Comment #25
merlinofchaos CreditAttribution: merlinofchaos commentedtheme_ function has no phpdoc comment.
IMO I'd rather have a template than a theme function here. But then, with a template I'd probably do away with the structure entirely.
But then again, we'd also like to change this to be a little more interactive at some point in the future, so maybe the structure is a good idea for that. This would be a nice place to pull up help documents and stuff in the future.
Comment #27
mikey_p CreditAttribution: mikey_p commentedIn IRC merlinofchaos suggested adding another setting (probably to admin/settings/site-information) with a path for when the front page has no content. I thought this sounded cool, as did eaton, however upon looking at how to implement this, it could be tricky as the variable for the front page is pulled into $_GET['q'] in drupal_init_path() in path.inc while in DRUPAL_BOOTSTRAP_PATH which is called before _drupal_bootstrap_full() where all modules (including the node module) are loaded.
I'm trying to find the best place to check this before we get to executing a handler, as we want to be able to switch handlers for this. The first thought that came to mind is node_init() but I don't know if that would be safe or considered kosher to reset $_GET['q'] there if there are no nodes for the front page.
Attached is a simple patch that does this. I suppose plans could be made to merge this with the first half of this issue, but I'd really like to see where http://groups.drupal.org/node/13270 goes first.
Comment #28
merlinofchaos CreditAttribution: merlinofchaos commentedWhat if node_page_default() just does this? Change $_GET['q'] to the new page, loads the router item and executes the page callback? Maybe that's a little bit more complex than it ought to be. Maybe it could lead to a menu_execute_handler('path')...
Comment #29
mikey_p CreditAttribution: mikey_p commentedThat is much simpler and keeps the logic all in one place, I think. The only downside to this, is that it only works as long as front page is set to 'node' (which is how it should work), but I don't know how to word the setting on admin/settings/site-information.
Perhaps this shouldn't even be a setting in the admin interface, but just a variable for developers to use as needed?
Comment #30
mikey_p CreditAttribution: mikey_p commentedMoved the current 'getting started' text from node.module to help.module and kept the drupal_alter and theme function (renamed however). This is now found at admin/help/getting-started.
In node.module when there are no front-page nodes, the variable 'site_empty_frontpage' (Defaults to 'admin/help/getting-started') is checked and $_GET['q'] is set on that, and then we call menu_execute_active_handler, which returns the getting started text. Downside to this is, the breadcrumb and menu seem to indicate that the user is within the help section when the URL is / (see attached image).
This is a start for the work outlined at http://groups.drupal.org/node/13270, once we get this in, we can change the getting-started page around in a separate issue.
Comment #31
mikey_p CreditAttribution: mikey_p commentedSetting this to needs review for feedback on this way of doing it.
Comment #32
drewish CreditAttribution: drewish commenteddoes it really need all the +5 -5 #weights?
$message doesn't seem like the best name.. $content?
Comment #33
drewish CreditAttribution: drewish commentedI think doing it as a template file would be best... the whole rendering via theme function seems really wonky.
Comment #35
mikey_p CreditAttribution: mikey_p commentedThis should pass all tests, will now display a short message if help module is disabled, and we also now allow anonymous access to admin/help/getting-started. I really like this approach but it seems to be getting a bit much for a simple problem.
Comment #36
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedDo we really want anonymous to be able to see anything at "admin/X/X"?
Also, I don't believe anonymous users need to see that information at all. We could set a simple redirect to "Getting started" page for the admins and devise something else for the anonymous or non-admins to see at the front page.
Comment #37
mikey_p CreditAttribution: mikey_p commentedComment #40
mikey_p CreditAttribution: mikey_p commentedThanks to #351235: hook_page_alter() this is superfluously redundant.
Comment #41
RobLoachMarked #338772: Theme the Welcome Message as duplicate. This issue still exists.....
Comment #42
mikey_p CreditAttribution: mikey_p commentedRobLoach pointed out that this is still somewhat of an issue. I think the best way to handle this, would be to change the whole welcome message over to a structured array (which should be returned, so that it can go through hook_page_alter), and then to add a theme function so that themers could override it without having to add a theme function in hook_page_alter.
Comment #43
mikey_p CreditAttribution: mikey_p commentedHere's another attempt without the drupal_alter call, and passing the message as array up through drupal_render_page().
Comment #44
mikey_p CreditAttribution: mikey_p commenteddoh. status.
Comment #45
Pasquallethe whole welcome message should be outside of the node_page_default() function, and it needs to be accessible even after the site has a front page..
I would like to see this implemented as a Help page after issue #299050: Help System - Master Patch is fixed. I hope help pages can be accessed even the help module is disabled..
Comment #46
Gurpartap Singh CreditAttribution: Gurpartap Singh commented^^ then why would you need the help "module"? just for playing with toggle checkbox? probably not ;)
Comment #47
PasqualleI don't understand your point. You can have a module and you can have an additional include file which works even the module is disabled. For example menus are still working after the menu module is disabled.
If you disable the help menu you can't search in the help or I don't know, you can have any functionality which is gone when the module is disabled and any functionality which works even the module is disabled..
So the welcome page should be a Help page and it should be accessible even the Help module is disabled as it needs to be displayed when.... Or maybe not, the front page could be empty when using the expert install profile. That also seems reasonable..
Comment #48
yoroy CreditAttribution: yoroy commentedWhat's the usabilty side of this? Any specific changes you'd like comments on? This is a rather technical discussion, I can't really tell what this changes for the user? If someone could summarize what the actual change is here then yes please & thanks.
Comment #49
mikey_p CreditAttribution: mikey_p commented@yoroy: Originally this issue started off with strictly a developers angle, of being able to alter the welcome message from module. The current patch is API and theme function changes only, with NO differences to the user/administrator.
I welcome changes to this usability wise, but as far as I've been able to tell in different issues, no consensus has been reached with how to deal with the broader issue of this support disappearing, or what to put in place of this support (i.e. the main page from support).
Comment #50
yoroy CreditAttribution: yoroy commentedOk, thanks. There are multiple ideas about how to improve the welcome page but indeed no consensus yet. Seems like this issue is not the place to start trying to do that.
Comment #52
dww@yoroy: Indeed. This issue is about making the code that generates the message a proper theme function so that sites can trivially change the text without hacking core. Changing the default text should definitely happen in a follow-up issue (patching core's default implementation of the new theme function), since it's very likely this issue will stall and die if a huge bikeshed argument breaks out in here. ;) Let's get the plumbing in place first, then we can worry about a new sink. ;) Thanks.
Comment #53
XanoI have been working on #419950: Remove /node as default front page, which is related to this issue. It doesn't really modify the welcome message, but it removes the dependency on Node.module for the welcome page. Basically, it does the same as HEAD does now, but the welcome message is located in common.inc (it would be a shame to depend on the help system for this, especially since novices might log out, don't see the message anymore and wonder what to do next) and it is displayed if no front page has been set.
The attached patch merges this issue and #419950: Remove /node as default front page. It uses Drupal 7's page mechanism to display the page. Modules will be able to change the message using hook_page_alter(), removing the need for a custom hook. The only known problem is that blocks don't want to appear.
Comment #54
XanoComment #56
Xano.
Comment #57
XanoThis patch needs to update Number of posts on main page at Administer > Content management > Post Settings.
Comment #58
matt2000 CreditAttribution: matt2000 commentedsubscribing
Comment #59
mikey_p CreditAttribution: mikey_p commentedThere are several other issues for this, please see them, and let this die.
Comment #60
dww@mikey_p: Links?
Comment #61
mikey_p CreditAttribution: mikey_p commentedhttp://drupal.org/node/475596
Comment #62
matt2000 CreditAttribution: matt2000 commentedDoes this issue need to be renamed?
Because /node as the default front, and the behavior of the welcome info, are two different things to me...
Comment #63
XanoThis issue is indeed about something else than the welcome screen, although the patch updates the same functions. Also, here at drupal.org we never directly set issues to closed. We let the bot take care of that.
Comment #64
RobLoach#475596: [meta-issue] Fix the unholy abomination that is the welcome screen
Comment #65
RobLoachWait a second, what's the scope of this issue? To just do some house cleaning in the default front page message?
Comment #66
matt2000 CreditAttribution: matt2000 commentedBased on the description, this is a duplicate of #79582: Add example content to the experimental out-of-the-box demo install profile.
Based on the title, I would expect this to be about changing the default value for the front page that is set at admin/settings/site-information . I think that can already be done easily enough in a profile?
Should this now be titled "Display help landing page via Form API" or can we just modify that via hook_help now thanks to #475596: [meta-issue] Fix the unholy abomination that is the welcome screen?
Comment #67
mikey_p CreditAttribution: mikey_p commentedSeriously, there are enough other places to go bike shed about this, and this has more or less been totally eclipsed by #475596: [meta-issue] Fix the unholy abomination that is the welcome screen and all it's followup issues. There's nothing left for this issue to patch anymore.
It's still staggering to me that after two years 475596 was committed and it still has %&*@ing hard coded HTML in it. I give up.
Comment #68
XanoThis issue is about ripping the welcome screen out of Node.module. It doesn't care about what the welcome screen does, just about getting it our of a module it doesn't belong in, so that module can be made optional. Nothing more, nothing less.
Comment #69
webchickThe main point of this issue (now that the welcome text is in help where it belongs and not barfed out when no nodes exist) seems to be the ability to alter the content of the welcome message. If so, a theme function is completely the wrong approach. While you can (ab)use theme functions to add/remove content to a page:
a) A theme function's main purpose is to style content that already exists, not to fundamentally change said content.
b) It means that the helpful instructions you added are now tied to your theme. If someone switches to Garland for debugging, your wonderful help is now lost.
hook_page_alter() is the right tool for the job here. This issue looks like it predates the addition of this hook, so maybe that's where the ire is coming from.
Marking duplicate, unless someone has other things from this patch that need to be pulled out and worked on.
Comment #70
merlinofchaos CreditAttribution: merlinofchaos commentedI agree with webchick on this one.
Comment #71
catchThis is essentially the same patch as mikey_p's #43 but updated for the new strings.
Comment #72
catchgraaar cross posted.
Comment #73
mikey_p CreditAttribution: mikey_p commentedActually catch I think what you are doing is still valid, and it's more hook_page_alter friendly.
Comment #74
webchickThis looks good.
Should we use #access here rather than hard-code the permission check?
Comment #75
XanoCould we focus on changing and theming the message elsewhere and just keep this issue for moving it out of Node.module?
Comment #76
webchickXano: The message is already out of node module. That's what #475596: [meta-issue] Fix the unholy abomination that is the welcome screen did. Please install HEAD and read the patch. :)
The current message that's being themed does belong in node.module because it needs to display something when the content list is empty.
Comment #77
Xano*Oops* Thanks Angie!
Comment #79
yoroy CreditAttribution: yoroy commentedSomebody should read from #69 down and asses if this still applies or close this again, I can't tell.
Comment #80
klonosIs this issue here still relevant?
Comment #81
eaton CreditAttribution: eaton commentedIMO, no. The new 'Node empty text' is a swappable views plugin, and a site builder can override it completely by customizing the front page View.
It didn't get fixed the way we expected, but it was fixed nevertheless!
Comment #82
dwwThen this doesn't need to be fixed in 8.x and back-ported, it can just happen directly in D7. ;)
Comment #83
snufkin CreditAttribution: snufkin commentedHere is a reroll of #71. When I tested it i realised that $message in the theme callback does not contain the 'message' part on the first level of the array, im not sure why. The way the $build array is compiled looks normal, so to work around this I had to add a dirty
$output = '<p>' . drupal_render($message['']['message']) . '</p>';
part intotheme_node_page_default()
.Comment #84
mitokens CreditAttribution: mitokens as a volunteer commented