Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Looks like user_user overrides ['History'] of Blog. Also, the blog returns an array of an array instead of an array with a themed form item.
Seems like you should be able to add sections to the fields expected by user_view, as well. Perhaps using something like the following in user_view:
$fields[$category] = array_merge($fields[$category], $content);
or however you would do that. (I'm trying to rush right now, and that is probably way off-base, but hopefully someone can get the idea of what I'm talking about.)
:)
Comment | File | Size | Author |
---|---|---|---|
#13 | user_view_1.patch | 5.54 KB | Zen |
#9 | hook_user_2.patch | 3.26 KB | ax |
#6 | user.module_view_0.patch | 1.38 KB | drewish |
#5 | hook_user_1.patch | 1.82 KB | ax |
#4 | hook_user_0.patch | 1.49 KB | ax |
Comments
Comment #1
drewish CreditAttribution: drewish commentedarray_merge() won't work because the first time you encounter $category, $fields[$category] isn't an array.
I think you'll have to do something like:
Please see the attached patch.
Comment #2
aaron CreditAttribution: aaron commentedThe issue is when you have enabled Blogs, and go the the User page. The blog module is trying to show a link to the recent blog posts under History. (blog.module's function blog_user) Currently, nothing shows up.
This patch is on the right track. However, after applying the patch, it shows the following when you go to 'user'. It's better than the default, which doesn't show a thing, but it's still not quite what we're looking for.
Comment #3
drewish CreditAttribution: drewish commentedWell, I think that there are actually two different bugs. My patch addresses the one in the user module. You might want to take a swing at the one for the blog module. Compare its output to that returned by other modules, it's returning form elements not html.
Comment #4
ax CreditAttribution: ax commentedthe problem is that both blog and user module's _user('view') hooks return wrong structures. former an
array(t('History') => $form)
with $form being a form array, not a string, latterarray(t('History') => array('history'=> drupal_get_form('member', $form)))
, with the value incorrectly being an array as well.fix attached. please review, test, apply. this "History: Array" at user/1 looks quite unprofessional :)
Comment #5
ax CreditAttribution: ax commentedoops - forgot the merging part
Comment #6
drewish CreditAttribution: drewish commentedax, I don't think it makes sense to remove that array.
Here's an update to my last patch that uses ax's fix for the blog module.
Comment #7
ax CreditAttribution: ax commenteddrewish, you are right. i was confused by the drupaldocs description of hook_user which says
apparently, this hasn't be updated after the relevant patch. so well - lets go on with your patch.
(note: using
+ $fields[$category][$heading] = $item;
instead of
+ $fields[$category][] = $content;
is still prone to overwriting: who tells me that i cannot use the 'blog' heading in the t('History') category for my custom module?)
Comment #8
drewish CreditAttribution: drewish commentedhumm. i think your right about the overwritting... any ideas on what the correct way to do the merge would be?
Comment #9
ax CreditAttribution: ax commenteddon't use user defined, but automatically generated $heading keys a la <module>-<number_of_heading_per_module>, eg. 'user-0', 'user-1', etc. in the end, the "relevant patch" (see last comment) was done to improve theming, ie. making the fields distinguishable - not to provide titles (this can be done when generating the string with the appropiate form functions).
the patch also addresses all of moshes suggestions from the "relevant patch".
TODO: update drupaldocs hook_user("view")
Comment #10
ax CreditAttribution: ax commenteddoes anyone care to test and review this? the symptom was "History: Array" instead of "History: member for xxx days; Blog: view recent blog posts" at user/1.
thanks!
Comment #11
brdwor CreditAttribution: brdwor commented+1, the patch worked and fixed the problem with blog.module. I also tested it with a contributed module that was causing the same problem and it works there too.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedComment #13
Zen CreditAttribution: Zen commentedThis is being continued from http://drupal.org/node/45444 . Apologies for the hijack of a RTC thread.
The attached patch is similar to the above patch by Ax, Drewish et al., and my own from the other thread, except:
-The ugly forms are gone. Less processing, cleaner mark-up, and greater styling control.
-The arrays are simpler and more efficient [less nesting].
-Rather than use an auto-numbering for the classes, the patch uses a class key to specify the class. IMO this offers a lot more flexibility [+ reuse] and keeps things tidy. The actual values for the class key are the same as before. This also saves one level of nesting. The $module prefix is still present
-The form mark-up is gone replaced with definition lists. The page looks and behaves the same as before.
AFAIK the only 3 instances in core where hook_user + 'view' are called have been taken care of with this patch.
Please review and update accordingly.
Thanks :)
-K
Comment #14
drummTested and it looks good. +1
Comment #15
ankur CreditAttribution: ankur commented+1
Tested the patch.
Comment #16
drewish CreditAttribution: drewish commented+1, zen's patch looks good.
Comment #17
Dries CreditAttribution: Dries commentedCommitted to HEAD. Thanks.
Comment #18
Dries CreditAttribution: Dries commentedComment #19
drummThis should be documented at http://drupal.org/node/22218
Comment #20
kvarnelis CreditAttribution: kvarnelis commentedI was having the problem detailed here: http://drupal.org/node/46759 ever since upgrading to beta 4.
No errors on upgrade. I would get "changes saved" after changing my password, but login results in "Sorry. Unrecognized username or password"
user history for me reads as "array"
The patch at the above node did nothing for me, but another user suggested I go here: http://drupal.org/node/46759
So I upgraded to CVS.
Now the password change still fails, however, I get.
Comment #21
kvarnelis CreditAttribution: kvarnelis commentedOh crap, sorry. i wish there was an edit button. i thought I was creating a new bug report, i guess not.
Comment #22
kvarnelis CreditAttribution: kvarnelis commentedyet again wishing for the edit button. i meant to say i went to the node drewish suggested: http://drupal.org/node/40200
Comment #23
Zen CreditAttribution: Zen commented@kvarnelis: Your password issue is not related to this. Drewish meant that the "User history just displays Array" bit might be related to this. If that is the case, please disable any contrib modules and test again. Reopen this issue if need be.
Thanks
-K
Comment #24
kvarnelis CreditAttribution: kvarnelis commentedthanks for pointing that out. should have done that in the first place. rusty debugging skills, but drupal 4.7 is making sure I re-learn them!
error happens when blog module (from CVS) is enabled and *all* other modules off.
error does not happen when blog module off and a whole host of other modules, including contrib modules on.
Comment #25
magico CreditAttribution: magico commentedThis seems to be against 4.7
Should be verified.
Comment #26
magico CreditAttribution: magico commentedWrongly reopened.
Comment #27
(not verified) CreditAttribution: commented