Hello,
If you have PHPBB-SEO mod installed and are having problems with it showing 0 friends even though you have friends added please read my fix below:
I've been having the same problems you've been having with SEO & Profile Friends List Mod. I figured out how to fix it a few minutes ago and thought I'd post my solution, I hope it works for you also or anyone else having this problem. I'm not super good with SQL so please let me know if my fix will cause any problems. So far I haven't ran into any ^_^ It seems that it was indeed the mod that needed a little tweaking to work properly with SEO but I also had already added the Zero Dupe changes. Those changes will also need to be made in addition to the original mod change below.
Here is my complete working code for the friend list mod part of memberlist.php:
Code: Select all
// friend list mod by ian-taylor.ca
$user_id = request_var('u', 0);
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (!$user_id) {
$user_name = request_var('un', '', true);
if ($user_name) {
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
$user_id = (int) $row['user_id'];
}
}
}
// www.phpBB-SEO.com SEO TOOLKIT END
$start = request_var('start', 0);
$limit = request_var('limit', intval($config['number_friends']));
$sql = 'SELECT u.user_avatar, u.username, u.user_colour, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, z.user_id, z.zebra_id, z.friend FROM ' . USERS_TABLE . ' u, ' . ZEBRA_TABLE . ' z WHERE u.user_id=z.zebra_id AND z.friend = 1 AND z.user_id = '.$user_id;
$result = $db->sql_query_limit($sql, $limit, $start);
while($row_av = $db->sql_fetchrow( $result )) {
$avatar_fri = get_user_avatar($row_av['user_avatar'], $row_av['user_avatar_type'], $row_av['user_avatar_width'], $row_av['user_avatar_height']);
$fri_id = $row_av['zebra_id'];
$av_size_size = $config['friend_avatar_size'];
$template->assign_block_vars('fri',array(
'FRI_ID' => $row_av['zebra_id'],
'FRI_AV' => $avatar_fri,
'USERNAME' => $row_av['username'],
'WIDTH' => $config['friend_avatar_size'],
'USER_COLOR' => $row_av['user_colour'],
'AV_LINK' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$fri_id"),
'FRI_AV_THUMB' => ($row_av['user_avatar']) ? get_user_avatar($row_av['user_avatar'], $row_av['user_avatar_type'], ($row_av['user_avatar_width'] > $row_av['user_avatar_height']) ? $av_size_size : ($av_size_size / $row_av['user_avatar_height']) * $row_av['user_avatar_width'], ($row_av['user_avatar_height'] > $row_av['user_avatar_width']) ? $av_size_size : ($av_size_size / $row_av['user_avatar_width']) * $row_av['user_avatar_height']) : '',
));
}
// count some stuff up for the pagination
$user_id = request_var('u', 0);
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (!$user_id) {
$user_name = request_var('un', '', true);
if ($user_name) {
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
$user_id = (int) $row['user_id'];
}
}
}
// www.phpBB-SEO.com SEO TOOLKIT END
$sql = 'SELECT COUNT(zebra_id) AS number_friends FROM '. ZEBRA_TABLE ." WHERE user_id=$user_id AND friend = 1";
$result = $db->sql_query($sql);
$total_friends = $db->sql_fetchfield('number_friends');
$db->sql_freeresult($result);
$pagination_friend = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$user_id");
$template->assign_vars(array(
'FRINATION' => generate_pagination($pagination_friend, $total_friends, $limit, $start),
'PAGE_NUMBER_F' => on_page($total_friends, $limit, $start),
'TOTAL_FRIENDS' => ($total_friends == 1) ? $user->lang['LIST_FRIEND'] : sprintf($user->lang['LIST_FRIENDS'], $total_friends),
));
// end friend list mod by ian-taylor.ca
If you compare my code above to your code you'll notice I made the following changes:
- I changed $profile to $user_id
- Added a second PHPSEO Toolkit under the new $user_id that was just changed from $profile
- I changed anything within the profile friends list mod that had used the variable $profile to $user_id
Here is what my zero dupe looks like in memberlist.php
Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN - Zero dupe
$phpbb_seo->seo_opt['zero_dupe']['redir_def'] = array(
'mode' => array('val' => 'viewprofile', 'keep' => true),
'u' => array('val' => $user_id, 'keep' => true, 'force' => true),
'start' => array('val' => ($_start = max(0, request_var('start', 0))), 'keep' => !empty($_start)),
);
$phpbb_seo->seo_chk_dupe();
// www.phpBB-SEO.com SEO TOOLKIT END - Zero dupe
That seemed to solve the problem for me. Before the change my friends list showed (0 Friends) and after the changes it shows (1 friend) and then I added a test friend and it shows (2 friends), so it seems to be working properly now.
P.S: I have SEO Rewrite, Zero Dupe and Strict all enabled to
YES. Please refer to
this post for further information.