Hello,
I just launched a site with an in-depth registration form. I have used various categories with number prefixes (1 Personal Information, 2 Home Address) etc. However when I click to view a user, all of the information is out of order - beginning with categories 7-9, then 1, then 6, and so on.
I just want all the information to be displayed in order! I tried making a custom user_profile.tpl.php (and editing template.php to redirect to the custom user_profile.tpl.php) but it isn't doing anything. Plus, I don't really need a custom layout (only the user and administrators can view the profiles). I just need the categories to be in order, and I looked into using php sort, but I don't think that's the right function or at least I'm not using it properly.
Can someone give me a quick fix to sort $category 0-9 (or 1-9, really)? Thanks!
Comments
To clarify, everything shows
To clarify, everything shows up in order on Admin > User Management > Profiles and also when users registers.
it is just the post-registration output at www.mysite.com/user/12 that is out of order.
I am having the same problem
I've got my profile categories named with numbers at the beginning, but in the user profile view (www.mysite.com/user) the categories display out of order. They display correctly in the profile admin page, just not when displaying a user's information.
Help!
Thanks.
same issue here!
Any ideas on this subject yet? How can we order categories on a profile page...?
www.druifdesign.nl
I did manage to sort the
I did manage to sort the profile categories by calling them in a certain order in my user-profile.tpl.php like this:
www.druifdesign.nl
Here is simple solution
I've got the same problem. There is one missing sorting which fixes everything.
If you go to /modules/user/user.pages.inc find template_preprocess_user_profile function and right before line
$variables['user_profile'] = implode($variables['profile']);add code to sort array by keys
ksort($variables['profile']);Now before user profile will be concatenated to a string the array keeping all the fields for user profile will be sorted by categories (keys in $variables['profile'] array are user's profile categories).
Note
This sorting is a string sorting the same as used on /admin/user/profile page. Just for consistency. This means that if you name your categories starting with numbers for instance "12. My category", this will be placed before "2. My category".
But don't think anyone will go so wild as to have more than 9 categories.
Just as an fyi-- the better
Just as an fyi-- the better way to do this would be to override the template_preprocess_user_profile function (that's the entire purpose of the template functions) in your theme's template.php file. Modifying core files essentially creates a fork that you must update and maintain yourself. Maybe not a big deal for a handful of sites, but gets old fast with anything more than that.
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
Good point and fix for user picture displayed at the bottom
Very good point.
And some tweak. I've just realized that the picture will be rendered at the bottom. To fix this the function should look like this:
Can't override function?
Using Drupal 6 I can't override template_preprocess_user_profile function by placing it in template.php under template folder (currently I'm using Garland as a theme but tried this for Bluemarine as well).
If I leave the function with unchanged name of course Drupal crashes as it gets name conflicts which means that it scans the template.php file.
I've tried to rename the function to sth like garland_preprocess_user_profile, phptemplate_preprocess_user_profile but Drupal completely ignores renamed function.
Any ideas?
garland_ and phptemplate_
garland_ and phptemplate_ should both work-- did you clear the theme registry?
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
Clearing cache doesn't help
Here are my steps:
However if I place ovverride function in template.php for let's say breadcrumbs named like garland_breadcrumb it does work!
I've run the site through Eclipse PDT debbug mode with breakpoint in my overriden garland_preprocess_user_profile function and it turned out that it's never reaches the code.
If I use devel Themer info and highlight profile box this is the info I'm getting:
Which just confirms my finding with Eclipse. I'm puzzled. Is there sth I'm missing?
BTW
I've tried this in Drupal5 overrrding in Garland's template.php and it works like a charm.
hmmm... what happens if you
hmmm... what happens if you try phptemplate_preprocess_user_profile in another theme?
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
different template the same story
I've tried Blumarine and the same story. I can override template_breadcrumb with sth like phptemplate_breadcrumb but phptemplate_preprocess_user_profile is completely ignored?!
Isn't it like this that "preprocess" functions need some different approach?
BTW I've tried to use Pushbutton theme and I'm not even able to override template_breadcrumb??? What happens is that template.php is not even read (you need to create one as this theme doesn't provide one). So I've created the file and put there template_breadcrumb function and PHP dind't complaine of name duplicate!
You need to copy
You need to copy modules/user/user-profile.tpl.php in your template directory.
Thanks!
I am new to drupal and have been very impressed so far unlike other CMS Ive used things work and act as expected. This has been the only real issue I have discovered. I am glad to see there is a knowledgeable user group as well.
I test the solution
I test the solution http://drupal.org/node/270352#comment-1064216
- I create function phptemplate_preprocess_user_profile(&$variables) { in my template.php files in my theme
- I add the user-profiles.tpl.php files in my theme
- clear cache...
But after that the user page is empty. The page are displaying but without content inside after the title.
If i add an "echo $variables['user_profile']" at the end of the phptemplate_preprocess_user_profile(&$variables) function they have nothing inside...
https://interface-network.com - Interface Network is an action and research technology governance agency.
yes it works!
problem solve!
Thanks!
/modules/user/user.pages.inc
right before line
$variables['user_profile'] = implode($variables['profile']);
add code to sort array by keys
ksort($variables['profile']);
- Thanks!!! It really works!
The following module provides
The following module provides a solution:
http://drupal.org/project/profile_category_weight
Profile categories how to reorder in Drupal 6.x
I realize this thread spans posts from several years.
I am trying to resolve the problem with the user profile view page in Drupal 6.x where the categories are not in order.
The profile_category_weight module only applies to the tab menu and not the profile view page itself.
The idea of an override in the template.php file sounds like the proper solution but does not work.
The only solution appears to be a hack to core modules/user/user.pages.inc to add the ksort line.
Unfortunately this also places the user picture at the bottom.
Can anyone suggest a better solution? Thanks.
Answering my own question
In case anyone else is interested, I have found that copying user-profile.tpl.php to the theme directory and editing it with the following seems to work:
I'm still not sure if this is the best way but at least it avoids hacking core.