News:

Join the Facebook Fan Page.

Main Menu

Team Page

Started by Diego Andrés, October 02, 2009, 04:56:36 PM

Previous topic - Next topic

PANIC12

Hello. I wanted to add an Advanced Profile Field to the teams page. How would I pull the data from the custom fields to enter into the TeamPage.php?

Diego Andrés

It's not supported at this time, maybe in the future.
You'd need to query the data in the Load() function in View.php

SMF Tricks - Free & Premium Responsive Themes for SMF.

PANIC12

Quote from: Diego Andrés on February 27, 2023, 09:50:57 PMYou'd need to query the data in the Load() function in View.php

Is there an easy way to do so? I've edited my teams template to how I wanted it setup, I just need to pull the field inputs.

PANIC12

would something like this work? https://www.simplemachines.org/community/index.php?topic=565469.msg4009580#msg4009580

I tried messing around with it, but with no success.


I inserted this code after the Check for the page before process-

// Pull Custom Field info
$request= $smcFunc['db_query']('', '
        SELECT mem.id_member, mem.real_name, th.variable, th.value, mg.group_name
        FROM {db_prefix}members AS mem
        LEFT JOIN {db_prefix}membergroups AS mg ON mem.id_group = mg.id_group
        LEFT JOIN {db_prefix}themes AS th ON mem.id_member = th.id_member
        WHERE th.variable IN ({array_string:variable})',
        array(
            'variable' => [
                'cust_discor',
                'cust_recrui',
'cust_recrui0',
'cust_volute'
            ],
        )
    );

$member = [];

while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!isset($member[$row['id_member']]))
{
$member[$row['id_member']] = [
'real_name' => $row['real_name'],
'group_name' => !empty($row['group_name']) ? $row['group_name'] : 'Regular Member',
'custom_values' => [],
];
    }

$member[$row['id_member']]['custom_values'][$row['variable']] = $row['value'];
}



and then i made these changes to the teams template:


<div class="tp_user_information">
<img class="tp_imgs" src="', $member['online']['image_href'], '" alt="', $member['online']['label'], '" />&nbsp;', $member['link'], '',empty($member['title']) ? '' : '&nbsp;-&nbsp;<strong>'.$member['title'].'</strong>' ,'<br />
<img class="tp_imgs" src="'. $settings['default_images_url']. '/teampage/volute.png" alt="'.$txt['TeamPage_volute'].'" title="'.$txt['TeamPage_volute'].'" />&nbsp;'.$txt['TeamPage_volute'].': ', $member['volute'], '<br />
<img class="tp_imgs" src="'. $settings['default_images_url']. '/teampage/discord.png" alt="'.$txt['TeamPage_discord'].'" title="'.$txt['TeamPage_discord'].'" />&nbsp;'.$txt['TeamPage_discord'].': '.$member['discord'].'<br />
<img class="tp_imgs" src="'. $settings['default_images_url']. '/teampage/stargmod.gif" alt="'.$txt['TeamPage_recruiter'].'" title="'.$txt['TeamPage_recruiter'].'" />&nbsp;'.$txt['TeamPage_recruiter'].': '.$member['recruiter'].'<br />
<img class="tp_imgs" src="'. $settings['default_images_url']. '/teampage/calendar.gif" alt="'.$txt['TeamPage_recruit_date'].'" title="'.$txt['TeamPage_recruit_date'].'" />&nbsp;'.$txt['TeamPage_recruit_date'].': '.$member['recruit_date'].'<br />
<img class="tp_imgs" src="'. $settings['default_images_url']. '/teampage/login.png" alt="'.$txt['TeamPage_last_login'].'" title="'.$txt['TeamPage_last_login'].'" />&nbsp;'.$txt['TeamPage_last_login'].': '.$member['last_login'].'
</div>
<span class="botslice"><span></span></span>
</div>';


The page loads with the field titles and icons, but user input is empty.

Diego Andrés

No that's for SMF 2.0.x.
Try this.
Sources/TeamPage/View.php
Code (Search) Select
// We got groups
Code (Add Before) Select
// Load the custom fields
$cust_members = [];
foreach ($context['teampage']['members'] as $team_group)
{
foreach($team_group['members'] as $team_member)
{
$cust_members[] = $team_member['id_member'];
}
}

$cust_members = array_unique($cust_members);
$search_custom_fields = [
'cust_gender',
'cust_loca'
];
$custom_fields = loadMemberCustomFields($cust_members, $search_custom_fields);
foreach ($context['teampage']['members'] as $id_group => $team_group)
{
foreach($team_group['members'] as $id_member => $team_member)
{
if (in_array($team_member['id_member'], array_keys($custom_fields)))
$context['teampage']['members'][$id_group]['members'][$id_member]['custom_fields'] = $custom_fields[$id_member];
}
}

And you can set the fields you want in: $search_custom_fields
Then you can access in the template to the value:

<span> Gender: ' . $user['custom_fields']['cust_gender']['value'] . '</span>
Just make sure to check if it exists:
', (!empty($user['custom_fields']['cust_gender']) ? '
<span> Gender: ' . $user['custom_fields']['cust_gender']['value'] . '</span>': ''), '


I might add it in a future update if I have time, because it would require some interface to select the custom fields.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Diego Andrés

5.4 - 04 March 2023
  • New Feature Added option to display custom profile fields.
  • Bug Fix Fixed attempting to load the team menu without access.

SMF Tricks - Free & Premium Responsive Themes for SMF.

PANIC12


Speed King

I got Fatal Error during 5.3.5 version uninstall:

[05-Mar-2023 06:44:07 Europe/Sofia] PHP Fatal error:  Uncaught Error: Failed opening required '/home/bulataka/public_html/BNF/Themes/default/languages/TeamPage/.english.php' (include_path='.:/opt/cpanel/ea-php82/root/usr/share/pear') in /home/bulataka/public_html/BNF/Sources/Load.php:3544
Stack trace:
#0 /home/bulataka/public_html/BNF/Sources/Load.php(3193): template_include('/home/bulataka/...')
#1 /home/bulataka/public_html/BNF/Sources/Load.php(3142): loadLanguage('TeamPage/', 'english', false)
#2 /home/bulataka/public_html/BNF/Sources/TeamPage/TeamPage.php(124): loadLanguage('TeamPage/')
#3 /home/bulataka/public_html/BNF/Sources/Subs.php(5784): TeamPage\TeamPage::hookButtons(Array)
#4 /home/bulataka/public_html/BNF/Sources/Subs.php(5589): call_integration_hook('integrate_menu_...', Array)
#5 /home/bulataka/public_html/BNF/Sources/Subs.php(4373): setupMenuContext()
#6 /home/bulataka/public_html/BNF/Sources/Subs.php(4530): setupThemeContext()
#7 /home/bulataka/public_html/BNF/Sources/Subs.php(4173): template_header()
#8 /home/bulataka/public_html/BNF/index.php(194): obExit(NULL, true, true)
#9 {main}
  thrown in /home/bulataka/public_html/BNF/Sources/Load.php on line 3544

But old version was uninstalled.
Default forum language is set to Bulgarian, but after that, I switched forum language to English, and then I have installed new 5.4 version - successful

Diego Andrés

Odd, I'll see if I can find anything related to it.
Currently working on a tiny update to clean it up a little bit.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Shades.

Team Page 5.4
SMF 2.1.3

Couple issues here:

1. Mod page still says 5.3.5 ;)
2. When uploading 5.4 it wont upload if 5.3.5 is uninstalled but still in the Packages directory (not a big deal)

And my main issue...

After selecting all the options in settings my Global Moderator is showing twice and the 2nd instance of their profile on the team page is showing "MY" profile information instead of theirs under their profile. (see attachment)

You cannot view this attachment.
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Shades.

And here are the errors I'm getting now:

QuoteError
Type of error
Undefined_vars
Error message
2: Undefined array key "members"
File
/home/*****/public_html/*****/Sources/TeamPage/View.php
Line
185
URL of page causing the error
https://*****.com/?action=team

Backtrace information
#0: smf_error_handler()
Called from /home/*****/public_html/*****/Sources/TeamPage/View.php on line 185
#1: Load()
Called from /home/*****/public_html/*****/Sources/TeamPage/View.php on line 68
#2: Main()
Called from /home/*****/public_html/*****/index.php on line 192

QuoteError
Type of error
General
Error message
2: foreach() argument must be of type array|object, null given
File
/home/*****/public_html/*****/Sources/TeamPage/View.php
Line
185
URL of page causing the error
https://*****.com/?action=team

Backtrace information
#0: smf_error_handler()
Called from /home/*****/public_html/*****/Sources/TeamPage/View.php on line 185
#1: Load()
Called from /home/*****/public_html/*****/Sources/TeamPage/View.php on line 68
#2: Main()
Called from /home/*****/public_html/*****/index.php on line 192
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Diego Andrés

Quote from: Shades. on March 05, 2023, 11:10:11 AM1. Mod page still says 5.3.5 ;)
2. When uploading 5.4 it wont upload if 5.3.5 is uninstalled but still in the Packages directory (not a big deal)

I didn't change the version in the package...
I will not fix it, new version coming soon.

Quote from: Shades. on March 05, 2023, 11:10:11 AMAfter selecting all the options in settings my Global Moderator is showing twice and the 2nd instance of their profile on the team page is showing "MY" profile information instead of theirs under their profile. (see attachment)

I think I've fixed it.

Quote from: Shades. on March 05, 2023, 11:53:19 AMAnd here are the errors I'm getting now:

Fixed.



Still need to do some more changes, will upload the new version later today likely.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Diego Andrés

5.4.1 - 05 March 2023
  • New Feature Added a new setting to select the sorting method (ID or Name).
  • Improvement Minor layout improvements and fixes.
  • Improvement Added custom fields to moderators.
  • Bug Fix Fixed issues when listing members.
  • Bug Fix Fixed order of the custom fields not matching their real order.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Speed King

With new 5.4.1 version, I get Fatal error message when I open Who's online list and someone is viewing Team page at this moment:

Fatal error: Uncaught TypeError: TeamPage\TeamPage::whoData(): Return value must be of type string, none returned in /home/bulataka/public_html/BNF/Sources/TeamPage/TeamPage.php:204 Stack trace: #0 /home/bulataka/public_html/BNF/Sources/Subs.php(5784): TeamPage\TeamPage->whoData(Array) #1 /home/bulataka/public_html/BNF/Sources/Who.php(468): call_integration_hook('integrate_whos_...', Array) #2 /home/bulataka/public_html/BNF/Sources/Who.php(213): determineActions(Array) #3 /home/bulataka/public_html/BNF/index.php(191): Who() #4 {main} thrown in /home/bulataka/public_html/BNF/Sources/TeamPage/TeamPage.php on line 204
Click =>

Diego Andrés

Thanks I'll fix it later.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Shades.

Quote from: Speed King on March 06, 2023, 03:38:54 PMWith new 5.4.1 version, I get Fatal error message when I open Who's online list and someone is viewing Team page at this moment:

Fatal error: Uncaught TypeError: TeamPage\TeamPage::whoData(): Return value must be of type string, none returned in /home/bulataka/public_html/BNF/Sources/TeamPage/TeamPage.php:204 Stack trace: #0 /home/bulataka/public_html/BNF/Sources/Subs.php(5784): TeamPage\TeamPage->whoData(Array) #1 /home/bulataka/public_html/BNF/Sources/Who.php(468): call_integration_hook('integrate_whos_...', Array) #2 /home/bulataka/public_html/BNF/Sources/Who.php(213): determineActions(Array) #3 /home/bulataka/public_html/BNF/index.php(191): Who() #4 {main} thrown in /home/bulataka/public_html/BNF/Sources/TeamPage/TeamPage.php on line 204
Click =>
Yep, I'm getting WSOD 500 error on the who's online page!
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Diego Andrés

Fixed in the new package.

5.4.2 - 06 March 2023
  • Bug Fix Fixed issue in the 'who' action.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Shades.

Works great thanks! 8)
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Ninja ZX-10RR

HTML entities are not converted to text in tab title, meaning if you use let's say an apostrophe in the page title (not the subaction), said page title will look like "whatever stuff before apostrophe&#039;".
Same thing happens on action=admin;area=teampage;sa=pages; as it lists the page in the same way.

The "Only available for left and right blocks" for many of the options seems not to be accurate, they work for bottom blocks as well. Or at least they work if bottom is the only selected layout (left and right empty, so disabled).
My use case is a memorial for a membergroup that is dedicated to deceased members, so a bit different from the original idea but works nonetheless :)

Thanks for the mod, regardless of whether you can fix these or not!
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Diego Andrés

I'll have a look when I can it should be an easy fix, thanks.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Advertisement: