If you care about the background of this patch, see http://drupal.org/node/79227.
This patch was RTBC at the very end of last release cycle but just missed the deadline. The patch unifies how we build the user page with how we build nodes. hook_user('view') will expect modules to add their fapi like bits to the content element, just like node rendering. user_view() will be consistent with node_view(), and not use a separate mechanism.
The upgrade process for modules that implement hook_user('view') is straightforward. Here is te diff from blog_user():
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access('edit own blog', $user)) {
- $items['blog'] = array('title' => t('Blog'),
- 'value' => l(t('View recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
- 'class' => 'blog',
+ $user->content['summary']['blog'] = array(
+ '#type' => 'profile_item',
+ '#title' => t('Blog'),
+ '#value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
+ '#attributes' => array('class' => 'blog'),
);
- return array(t('History') => $items);
}
}
Comments
Comment #1
eaton commentedA big ol' huge +1 from me on this. This means yet one more data structure would be stored in our standard #format. Altering it becomes easier and more predictable as well.
Comment #2
ChrisKennedy commentedLooks good to me once a few coding style errors are fixed. There's some weird spacing at the end of the first hunk, .profile dd needs a space, and the second output line in theme_profile_item() has one extra space near the end.
Is the capitalization change to 'view recent blog entries' intentional?
Comment #3
moshe weitzman commentedfixed code style issues as mentioned by chris (i did not find any anomoly in theme_profile_item). since chris tested it, and eaton approves it, we move to RTBC.
Comment #4
ChrisKennedy commentedLooks like you attached the wrong patch.
Comment #5
moshe weitzman commentedindeed. here it is.
Comment #6
chx commentedyes, yes, YES!
But, the patch had TABs in it. Blasphemy!
Comment #7
moshe weitzman commentedi verified that chx' reroll still works as expected. here it is, without any fuzz.
if you don't see any profile info on profile page, you might need to clear theme cache. i use the link in the devel block for all my cache clearing needs.
Comment #8
moshe weitzman commentedthis has been RTBC for 10 days without any feedback from core committers. i know that all are so busy so i do not complain. i'd just like to see this in D6 and since it is an API change, it would be good to find flaws now.
Comment #9
moshe weitzman commentednow has a conflict in user.css. i'm taking a break from this one. i hope someone else pushes it though.
Comment #10
ChrisKennedy commentedRe-rolled and fixed three minor bugs while I was at it.
Comment #11
ChrisKennedy commentedOops, here is the right patch.
Comment #12
Steven commentedThe alter $type is 'alter'? That doesn't sound right at all.
The comment typography is also off in several places.
Comment #13
ChrisKennedy commentedRe-roll.
Comment #14
moshe weitzman commentedtested - works as designed.
Comment #15
moshe weitzman commentedstill applies and works as designed. this has been aging here for a while now ...
Comment #16
moshe weitzman commentedfixed minor code style issues pointed out by steven, and moved drupal_render() call to a new user_profile.tpl.php.
Comment #17
moshe weitzman commentedi reflowed the comments in user_profile.tpl.php as suggested.
if anyone rerolls this, don't forget about the new modules/user/user_profile.tpl.php which is in the patch. you can easily add new files into a patch with fakeadd: http://www.cygwin.com/ml/binutils/2004-04/msg00537.html
Comment #18
moshe weitzman commentedpatch attached
Comment #19
Steven commented?>at the end of our PHP files.Comment #20
moshe weitzman commentedI implemented all of Steven's suggestions ... That check_plain() was removed from profile_category template and check functions were added to profile_view_profile(). That's the only user submitted content that applies. I used check_plain() for titles. If someone prefers check_markup() there, please help me with the css that goesd with it since check_markup() adds some markup that increases spacing.
Comment #21
moshe weitzman commentedrerolled with PRE close tag and minor code style fix per Steven's latest review.
Comment #22
Steven commentedThis pattern of putting the closing bracket in the printed variable seems very themer-unfriendly. Can't we simply use separate placeholders for attributes and title/value?
Comment #23
moshe weitzman commentededited that template file as suggested.
Comment #24
Steven commentedTested locally, works as expected. Still some code style errors though. The default styling was also ugly in Garland.
Committed to HEAD with some tweaks.
Upgrade docs need to be posted to the handbook.
Comment #25
moshe weitzman commentedi added upgrade docs and updated api.drupal.org docs.
Comment #26
(not verified) commented