MEMBERLIST_BODY.HTML customisation

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
mmccreadie
Registered User
Posts: 3
Joined: Mon Jul 20, 2020 2:44 pm

MEMBERLIST_BODY.HTML customisation

Post by mmccreadie »

v3.3.11
I've been banging my head on this issue for about three weeks, which none of the users of the boards concerned will even care about, but it bothers me because it seems like it should work but doesn't.

As background I've added three additional columns to PHPBB_USERS; USER_FIRSTNAME, USER_SURNAME AND USER_DESIGNATION and I thought it would be an easy task to get them to appear in the Memberlist table as separate columns but for the life of me I cannot get the data to appear.

My query in MEMBERLIST.PHP is presumably correct. I created a custom page and the data is reported and also appears on MEMBERLIST_VIEW.HTML however regardless of how I try to amend the array to include and output these fields to MEMBERLIST_BODY.HTML they never appear.

I've reviewed and followed previous threads where similar things have been done and I am aware I could use Custom Profile fields, which in some ways would just as good if not better in this instance, however further down the development line this may not be acceptable as a solution and at the very least as a point of theoretical understanding I'd appreciate if someone could explain to me where I'm going wrong with this...
Last edited by Mick on Thu May 23, 2024 7:06 am, edited 1 time in total.
Reason: Solved.
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6311
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: MEMBERLIST_BODY.HTML customisation

Post by thecoalman »

Did you purge the cache? Anytime you make edit to template you need to purge the cache.

Edit: Additionally under load settings you can disable this behavior for development environment.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
danieltj
Infrastructure Team Member
Infrastructure Team Member
Posts: 521
Joined: Thu May 03, 2018 9:32 pm
Location: United Kingdom
Name: Daniel James

Re: MEMBERLIST_BODY.HTML customisation

Post by danieltj »

Can you share your code you've added so far and to what locations? It could be that the data is not being loaded correctly as a template variable and as such is not appearing because it's not being passed to the template. Having said that, without seeing your code it's impossible to know why it's not working for you.
💷 Purchase the Awesome Payments extension today!
Monetise your forum with one off payments and subscriptions.

Need a premium extension created? Send me a PM.
User avatar
warmweer
Jr. Extension Validator
Posts: 11660
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium

Re: MEMBERLIST_BODY.HTML customisation

Post by warmweer »

mmccreadie wrote: Tue May 21, 2024 3:34 pm ...
I've reviewed and followed previous threads where similar things have been done and I am aware I could use Custom Profile fields, which in some ways would just as good if not better in this instance, however further down the development line this may not be acceptable as a solution and at the very least as a point of theoretical understanding I'd appreciate if someone could explain to me where I'm going wrong with this...
I'm puzzled as to why you think/fear CPF may not be acceptable as a solution.

CPF is a default feature, has options to choose from as to field type/size/display options, even language options.
What more do you need?
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
mmccreadie
Registered User
Posts: 3
Joined: Mon Jul 20, 2020 2:44 pm

Re: MEMBERLIST_BODY.HTML customisation

Post by mmccreadie »

Thanks all for your considered responses...
thecoalman wrote: Tue May 21, 2024 3:38 pm Did you purge the cache? Anytime you make edit to template you need to purge the cache.
I purge the cache if I change the .HTML but it's mostly been edits to the .PHP file trying to get it to produce an output, but thanks for the tip about disabling that during development.
danieltj wrote: Tue May 21, 2024 4:01 pm Can you share your code you've added so far and to what locations? It could be that the data is not being loaded correctly as a template variable and as such is not appearing because it's not being passed to the template. Having said that, without seeing your code it's impossible to know why it's not working for you.
I tend to go back to the default file after a fruitless session of trying to get it to work so I don't have modified files. The code I've used in my custom page for testing is:

MEMBERLIST_BODY.HTML
after

Code: Select all

<td><span class="rank-img"><!-- EVENT memberlist_body_rank_prepend --><!-- IF memberrow.RANK_IMG -->{memberrow.RANK_IMG}<!-- ELSE -->{memberrow.RANK_TITLE}<!-- ENDIF --><!-- EVENT memberlist_body_rank_append --></span><!-- IF S_IN_SEARCH_POPUP and not S_SELECT_SINGLE --><input type="checkbox" name="user" value="{memberrow.USERNAME}" /> <!-- ENDIF --><!-- EVENT memberlist_body_username_prepend -->{memberrow.USERNAME_FULL}<!-- IF memberrow.S_INACTIVE --> ({L_INACTIVE})<!-- ENDIF --><!-- EVENT memberlist_body_username_append --><!-- IF S_IN_SEARCH_POPUP --><br />[&nbsp;<a href="#" onclick="insert_single_user('#results', '{memberrow.A_USERNAME}'); return false;">{L_SELECT}</a>&nbsp;]<!-- ENDIF --></td>
insert

Code: Select all

    <td><!-- IF USER_DESIGNATION  -->{USER_DESIGNATION}<!-- ELSE -->ID<!-- ENDIF --></td>
    <td><!-- IF USER_FIRSTNAME -->{USER_FIRSTNAME} {USER_SURNAME}<!-- ELSE -->Full Name<!-- ENDIF --></td>
MEMBERLIST.PHP
insert

Code: Select all

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$user_id = $user->data['user_id'];
and

Code: Select all

$sql = 'SELECT memberid, user_firstname, user_lastname FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user_id; 
$result = $db->sql_query($sql);
$user_data = $db->sql_fetchrow($result);

$template->assign_vars(array(
    'MEMBER_ID' => $user_data['memberid'],
    'USER_FIRSTNAME' => $user_data['user_firstname'],
    'USER_LASTNAME' => $user_data['user_lastname'],
));
Where to insert this is the basis of my question. My guess that it was somewhere between

Code: Select all

	default:
		// The basic memberlist
and

Code: Select all

		else if ($first_char)
		{
			$sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char());
		}
warmweer wrote: Tue May 21, 2024 4:37 pm I'm puzzled as to why you think/fear CPF may not be acceptable as a solution.

CPF is a default feature, has options to choose from as to field type/size/display options, even language options.
What more do you need?
"may not be acceptable as a solution... in my own head". I didn't say it was a rational fear!
Since I already have the data in PHP_USERS where users can't make alterations it seems redundant to duplicate it in PHPBB_PROFILE_FIELDS_DATA where it'll always be editable to my knowledge. I'm a simple man blundering my way through this and I like the idea having my user data in a single user table I guess..?

As mentioned I know I can use CPF and if there's really no other answer I will and use <!-- IF 0 --> to hide the <!-- BEGIN custom_fields --> block of CPF data from the table rather than duplicate it, but I won't like it. ;)
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53525
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: MEMBERLIST_BODY.HTML customisation

Post by Brf »

memberlist_body.html is for the memberlist table. All of the member data is part for that user's "memberrow". If you are add more fields to a user, you would have to add them to the memberrow for the template assign_block_vars, not to assign_vars as you are doing. It looks like you are attempting to retrieve the values for the viewing user, not for the users in the table.

I am not sure why you would be duplicating the session inside memberlist.php you should be using the existing session.
User avatar
warmweer
Jr. Extension Validator
Posts: 11660
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium

Re: MEMBERLIST_BODY.HTML customisation

Post by warmweer »

Try this: (I tested this just now and unless I overlooked something it should do exactly what you want.) (Disclaimer : it was a rush job so I may be wrong: anyway it's always better let someone else than the "designer" test a setup)

ACP >Custom Profile Fields > create a new CPF e.g. surname

Visibility options

Display in user control panel:
The user is able to change this profile field within the user control panel. >>> do NOT tick that

Display on registration screen:
If this option is enabled, the field will be displayed on registration. >>> tick that

Required filed > tick that
Show field if no value was selected:> tick that


Unless I missed something:

A new user has to fill in the field when registering, but he can't change it later. (but you as admin can)

However I didn't test an already registered user who wasn't subject to the requirement for that field when registering.
Those will have that field empty but won't be able to edit it, but you as admin can edit that field so you'll have to contact those users and ask what needs to be filled in for that field.

Added: the edits you tried to use will work partly but you'll have the same problem with users who didn't fill in that field.
+ the real downside is that you'll have to redo the edits with each update. (probably easy for the html files, but the PHP code may not be compatible with new versions of phpBB.
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
mmccreadie
Registered User
Posts: 3
Joined: Mon Jul 20, 2020 2:44 pm

Re: MEMBERLIST_BODY.HTML customisation

Post by mmccreadie »

Benelux's finest Warmweer has won the topic and my thanks.
While I still think it'll come back and bite me I've used CPF and made some template changes to achieve my desired output so I can move on from this pure aesthetic issue to the actual problematic bit of development. Expect more posts begging for help soon.

My thanks to BRF for the input though as their post from 2007 on similar customisation was what started me down this accursed path!

Return to “phpBB Custom Coding”