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

eaton’s picture

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

ChrisKennedy’s picture

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

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new29.02 KB

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

ChrisKennedy’s picture

Looks like you attached the wrong patch.

moshe weitzman’s picture

StatusFileSize
new9.41 KB

indeed. here it is.

chx’s picture

StatusFileSize
new9.41 KB

yes, yes, YES!

But, the patch had TABs in it. Blasphemy!

moshe weitzman’s picture

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

moshe weitzman’s picture

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

moshe weitzman’s picture

Assigned: moshe weitzman » Unassigned
Status: Reviewed & tested by the community » Needs work

now has a conflict in user.css. i'm taking a break from this one. i hope someone else pushes it though.

ChrisKennedy’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new10.29 KB

Re-rolled and fixed three minor bugs while I was at it.

ChrisKennedy’s picture

StatusFileSize
new10.29 KB

Oops, here is the right patch.

Steven’s picture

Status: Reviewed & tested by the community » Needs work
+  drupal_alter('alter', $edit, $account);

The alter $type is 'alter'? That doesn't sound right at all.

The comment typography is also off in several places.

ChrisKennedy’s picture

Status: Needs work » Needs review
StatusFileSize
new10.36 KB

Re-roll.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

tested - works as designed.

moshe weitzman’s picture

still applies and works as designed. this has been aging here for a while now ...

moshe weitzman’s picture

StatusFileSize
new11.53 KB

fixed minor code style issues pointed out by steven, and moved drupal_render() call to a new user_profile.tpl.php.

moshe weitzman’s picture

i 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

moshe weitzman’s picture

StatusFileSize
new11.46 KB

patch attached

Steven’s picture

Status: Reviewed & tested by the community » Needs work
  • The use of check_plain() for #title in the profile_category themeable goes against Form API conventions. Form element titles have always been HTML, and any user submitted data in them should be escaped by the module.
  • Since each profile field is by default output to a definition list item, this .tpl.php is a bit useless without corresponding tpl.php's for profile_category/item (which should probably be renamed to user_profile_...).
  • No ?> at the end of our PHP files.
moshe weitzman’s picture

Status: Needs work » Needs review
StatusFileSize
new11.51 KB

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

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new11.52 KB

rerolled with PRE close tag and minor code style fix per Steven's latest review.

Steven’s picture

<?php

if ($element['#title'] != '') {
  $dt = (isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '') .'>'. $element['#title'];
  $dd = (isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '') .'>'. $element['#value'];
  ?>
  <dt<?php print $dt ?></dt>
  <dd<?php print $dd ?></dd>
<?php } ?>

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

moshe weitzman’s picture

StatusFileSize
new11.29 KB

edited that template file as suggested.

Steven’s picture

Status: Reviewed & tested by the community » Needs work

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

moshe weitzman’s picture

Status: Needs work » Fixed

i added upgrade docs and updated api.drupal.org docs.

Anonymous’s picture

Status: Fixed » Closed (fixed)