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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Needs review » Needs work

+ return($form); lose () and also lose drupal_get_form, just call the function and call drupal_render on it. This is not a form.

eaton’s picture

Agreed, 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.

merlinofchaos’s picture

Wouldn't a theme function be better than a form alter?

dmitrig01’s picture

This can be really useful in install profiles.

mikey_p’s picture

Title: Make node_page_default use Forms API so that the default welcome message can be modified » Make node_page_default use drupal_render and add theme_default_message
Status: Needs work » Needs review
FileSize
6.92 KB

Well here's a second go around. Added function theme_default_message and removed prefix and suffix stuff from the structured array.

mikey_p’s picture

Title: Make node_page_default use drupal_render and add theme_default_message » Make node_page_default use it's own theme function
FileSize
6.92 KB

I fixed the description, and fixed a comment in the code, as well as a typo.

merlinofchaos’s picture

Status: Needs review » Needs work

Without 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).

eaton’s picture

Or, 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.

mikey_p’s picture

@ 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

eaton’s picture

I'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().

mikey_p’s picture

Version: 6.x-dev » 7.x-dev

I 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.

mikey_p’s picture

Status: Needs work » Needs review
FileSize
6.45 KB

Here'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.

floretan’s picture

Status: Needs review » Needs work

The 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).

mikey_p’s picture

Status: Needs work » Needs review
FileSize
6.46 KB

Changed the drupal_alter and theme to 'default_welcome_page'

merlinofchaos’s picture

No, 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.

floretan’s picture

@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".

mikey_p’s picture

Reroll

snufkin’s picture

Patch still applies, rerolled against head.

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

dww’s picture

Category: feature » bug

Sorry, 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...

mikey_p’s picture

I 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.

mikey_p’s picture

Status: Needs work » Needs review
FileSize
6.53 KB

Well 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?

mikey_p’s picture

Status: Needs review » Needs work

Duh, just realized I could specify #theme for drupal_render(). I'll give that a try and then update..

mikey_p’s picture

Status: Needs work » Needs review
FileSize
8.69 KB

Okay 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.

merlinofchaos’s picture

theme_ 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.

Status: Needs review » Needs work

The last submitted patch failed testing.

mikey_p’s picture

FileSize
2.42 KB

In 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.

merlinofchaos’s picture

What 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')...

mikey_p’s picture

FileSize
4.74 KB

That 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?

mikey_p’s picture

Moved 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.

mikey_p’s picture

Status: Needs work » Needs review

Setting this to needs review for feedback on this way of doing it.

drewish’s picture

does it really need all the +5 -5 #weights?

$message doesn't seem like the best name.. $content?

drewish’s picture

I think doing it as a template file would be best... the whole rendering via theme function seems really wonky.

Status: Needs review » Needs work

The last submitted patch failed testing.

mikey_p’s picture

Status: Needs work » Needs review
FileSize
8.49 KB

This 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.

Gurpartap Singh’s picture

Do 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.

mikey_p’s picture

Issue tags: +Needs usability review

Status: Needs review » Needs work

The last submitted patch failed testing.

mikey_p’s picture

Status: Needs work » Closed (duplicate)

Thanks to #351235: hook_page_alter() this is superfluously redundant.

RobLoach’s picture

Status: Closed (duplicate) » Active

Marked #338772: Theme the Welcome Message as duplicate. This issue still exists.....

mikey_p’s picture

Status: Active » Needs work

RobLoach 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.

mikey_p’s picture

FileSize
5.74 KB

Here's another attempt without the drupal_alter call, and passing the message as array up through drupal_render_page().

mikey_p’s picture

Status: Needs work » Needs review

doh. status.

Pasqualle’s picture

the 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..

Gurpartap Singh’s picture

^^ then why would you need the help "module"? just for playing with toggle checkbox? probably not ;)

Pasqualle’s picture

I 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..

yoroy’s picture

What'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.

mikey_p’s picture

@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).

yoroy’s picture

Issue tags: -Needs usability review

Ok, 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.

Status: Needs review » Needs work

The last submitted patch failed testing.

dww’s picture

@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.

Xano’s picture

Assigned: Unassigned » Xano
Status: Needs work » Needs review
FileSize
12.93 KB

I 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.

Xano’s picture

Title: Make node_page_default use it's own theme function » Remove /node as default front page and use drupal_get_page()

Status: Needs review » Needs work

The last submitted patch failed testing.

Xano’s picture

Issue tags: +Cleanup

.

Xano’s picture

This patch needs to update Number of posts on main page at Administer > Content management > Post Settings.

matt2000’s picture

subscribing

mikey_p’s picture

Status: Needs work » Closed (fixed)

There are several other issues for this, please see them, and let this die.

dww’s picture

@mikey_p: Links?

mikey_p’s picture

matt2000’s picture

Does 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...

Xano’s picture

Status: Closed (fixed) » Needs work

This 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.

RobLoach’s picture

RobLoach’s picture

Status: Closed (duplicate) » Needs work

Wait a second, what's the scope of this issue? To just do some house cleaning in the default front page message?

matt2000’s picture

Based 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?

mikey_p’s picture

Seriously, 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.

Xano’s picture

This 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.

webchick’s picture

Status: Needs work » Closed (duplicate)

The 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.

merlinofchaos’s picture

I agree with webchick on this one.

catch’s picture

Title: Remove /node as default front page and use drupal_get_page() » Make 'node' empty text themable.
Status: Closed (duplicate) » Needs review
FileSize
2.29 KB

This is essentially the same patch as mikey_p's #43 but updated for the new strings.

catch’s picture

Status: Needs review » Closed (duplicate)

graaar cross posted.

mikey_p’s picture

Status: Closed (duplicate) » Needs review

Actually catch I think what you are doing is still valid, and it's more hook_page_alter friendly.

webchick’s picture

This looks good.

Should we use #access here rather than hard-code the permission check?

Xano’s picture

Could we focus on changing and theming the message elsewhere and just keep this issue for moving it out of Node.module?

webchick’s picture

Xano: 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.

Xano’s picture

*Oops* Thanks Angie!

Status: Needs review » Needs work

The last submitted patch failed testing.

yoroy’s picture

Version: 7.x-dev » 8.x-dev
Assigned: Xano » Unassigned

Somebody should read from #69 down and asses if this still applies or close this again, I can't tell.

klonos’s picture

Is this issue here still relevant?

eaton’s picture

Status: Needs work » Fixed

Is this issue here still relevant?

IMO, 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!

dww’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Needs work

Then this doesn't need to be fixed in 8.x and back-ported, it can just happen directly in D7. ;)

snufkin’s picture

Here 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 into theme_node_page_default().

mitokens’s picture