Don't show a field in view profile if value is null?

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Don't show a field in view profile if value is null?

Post by bgaidan »

I have added numerous fields to my registration and profile areas however some of these fields are specialized and many people will not be filing them in.

What I'd like to do is have these fields only show up in the view profile page if the user has entered a value.

Take the field "Maiden Name" for example. Since a majority of my members won't be filling out this field, I don't want an empty "Maiden Name:" showing up in everyone's profile. I'd much rather have just a blank line or something.

I'm not worried much about the effect this will have on the general layout of the profile as I can work around that with the placement of these lines.

Thanks for readin'!
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Post by bgaidan »

It can't be that hard.......can it?
Posco Deepdelver
Registered User
Posts: 23
Joined: Fri May 28, 2004 11:00 pm
Location: Turn around...

Post by Posco Deepdelver »

I have an idea, I think I can make this work. When my webhost stops being stupid, I'll try to see if I can rig something up.
If some brand of paper towel is better than the leading brand, why aren't they the leading brand?
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Post by bgaidan »

Sweet! I'm looking forward to what you find!
User avatar
OmegaQuest
Registered User
Posts: 76
Joined: Mon Sep 01, 2003 9:12 pm
Location: Washington, DC

Post by OmegaQuest »

You can try something like this in the usercp_viewprofile.php file:

Code: Select all

if ( !empty($profiledata['user_maidenname']) )
{
	$profile_maidenname = '<tr><td> ....... What ever you want the Profile to view </td></tr>';
}
else
{
	$profile_maidenname = '';
}
Then look for:

Code: Select all

	'POSTS' => $profiledata['user_posts'],
and add something like this:

Code: Select all

	'MAIDENNAME' => $profile_maidenname,
Then in the profile_view_body.tpl file, replace the lines that have the <td><tr> .... that is for your Maiden Names and replace it with something like this:

Code: Select all

{MAIDENNAME}
Note the Values might be differant for you, because I guessed on the Database Values because I do not have Maiden Names on my Forums...

I hope that helps
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Post by bgaidan »

Thanks! I give that a shot sometime today when I get a chance.
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Post by bgaidan »

I haven't tried this yet, but could this same general mehtod also work for viewtopic? I have a couple of extra lines showing up under the user's name....but if the field is left blank I'd like it to not show up.
User avatar
OmegaQuest
Registered User
Posts: 76
Joined: Mon Sep 01, 2003 9:12 pm
Location: Washington, DC

Post by OmegaQuest »

Yes
bgaidan
Registered User
Posts: 43
Joined: Sun Apr 11, 2004 7:27 pm

Post by bgaidan »

Yeah dude! You rock!


Worked like a charm in the profile!
Post Reply

Return to “[2.0.x] MOD Requests”