Add & Create Social Media Icons To Profiles

Started by hcfwesker, January 30, 2012, 10:06:52 AM

Previous topic - Next topic

hcfwesker

#200
Well, I could have it where the http://www.linkedin.com/ pre-link is auto installed, but it's up to members to add what comes after that.  then I can shorten the amount of characters allowed to stop links from being added.

Ex. http://www.linkedin.com/pub/ankkita-jain/13/311/a94  , that member would have to add  pub/ankkita-jain/13/311/a94  to the field box.  There's so many sub directories in LinkedIn I can't add them all lol.  Reason I made it so the entire link had to be added, since I thought this would make it more confusing for forum members for adding their LI profile links.

Bob Perry of Web Presence Consulting

Quote from: hcfwesker on February 03, 2013, 09:35:03 PM
Well, I could have it where the http://www.linkedin.com/ pre-link is auto installed, but it's up to members to add what comes after that.  then I can shorten the amount of characters allowed to stop links from being added.

Ex. http://www.linkedin.com/pub/ankkita-jain/13/311/a94  , that member would have to add  pub/ankkita-jain/13/311/a94  to the field box.  There's so many sub directories in LinkedIn I can't add them all lol.  Reason I made it so the entire link had to be added, since I thought this would make it more confusing for forum members for adding their LI profile links.

I'm thinking a better way would be to parse the users entered link, checking that the "http://www.linkedin.com" is correctly matched to a static copy of that phrase of text...
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

hcfwesker

Something like this?

'gamer_psn' => array(
'type' => 'text',
'label' => $txt['gamer_psn'],
'subtext' => $txt['your_gamer_psn'],
'size' => 16,
'input_attr' => array('maxlength="20"'),
'permission' => 'profile_extra',
'input_validate' => create_function('&$value', '
$value = preg_replace(\'/[^a-zA-Z0-9-_]+/\', \'\', $value);
return true;
'),
),


'input_validate' => create_function('&$value', '
$value = preg_replace(\'/[^a-zA-Z0-9-_]+/\', \'\', $value);
return true;


Not sure how to add that link so it validates.


Arantor

Regular expressions are your friend.

As an off-hand... (and thus untested)
if (preg_match('~^https?://(www\.)?linkedin\.com/pub/[^/]+/?~i', $value))
// do something magical because it looks legit


(somewhere inside input_validate)

MarkS

hi i cant find this Admin Settings (optional)* Admin > Configuration > Profile Fields i want to un tick some of then i only want fb and twitter sorry i can not find it

vbgamer45

Quote from: MarkS on February 04, 2013, 06:10:00 PM
hi i cant find this Admin Settings (optional)* Admin > Configuration > Profile Fields i want to un tick some of then i only want fb and twitter sorry i can not find it
If SMF 2.0 first enable them under Admin -> Core Features -> Advanced Profile Fields

There is then a setting under Features and Options -> Profile Fields
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

MarkS

i new it would be easy just knowing what ive not done thanks

hcfwesker

Sorry about that, I always activate Profile Fields, so didn't realize that wouldn't show if those setting wasn't activated first.  but the update I'm preparing will fix this issue. 

Thanx for the assistance, vbgamer45 :)

demlak

Translation German informal:
Quote<file name="$languagedir/Modifications.german_informal.php">
      <operation>
         <search position="after"><![CDATA[?>]]></search>
            <add><![CDATA[$txt['smi_buddies_title'] = 'Soziale Netzwerke';
$txt['smi_facebook_title'] = 'Facebook';
$txt['smi_facebook_desc'] = 'Dein Facebook Benutzername.';
$txt['smi_myspace_title'] = 'MySpace';
$txt['smi_myspace_desc'] = 'Dein MySpace Benutzername.';
$txt['smi_twitter_title'] = 'Twitter';
$txt['smi_twitter_desc'] = 'Dein Twitter Benutzername.';
$txt['smi_youtube_title'] = 'Youtube';
$txt['smi_youtube_desc'] = 'Dein Youtube Benutzername.';
$txt['smi_deviantart_title'] = 'DeviantArt';
$txt['smi_deviantart_desc'] = 'Dein DeviantArt Benutzername.';
$txt['smi_pinterest_title'] = 'Pinterest';
$txt['smi_pinterest_desc'] = 'Dein Pinterest Benutzername.';
$txt['smi_googleplus_title'] = 'Google+';
$txt['smi_googleplus_desc'] = 'Deine Google+ BenutzerID.';
$txt['smi_linkedin_title'] = 'LinkedIn';
$txt['smi_linkedin_desc'] = 'Dein LinkedIn Profillink.';

]]></add>
        </operation>
   </file>

pastorvictor

#209
This is a great mod!

I just have one issue: for some reason the only field that shows in Spanish is the "MSN" field....everything else is in English. My board's designed for a Spanish-speaking audience, so it's important to me that everything gets translated. Can I fix this manually or what would you suggest?

I'm attaching a screen shot in case it helps.

hcfwesker



languages/Modifications.spanish.php

Check that file and see if these got added. Plus if you wanna be extra sure, replace the ones in Modifications.english.php for the ones below as well.

$txt['smi_facebook_title'] = 'Facebook';
$txt['smi_facebook_desc'] = 'Su Usuario en Facebook.';         
$txt['smi_myspace_title'] = 'MySpace';
$txt['smi_myspace_desc'] = 'Su Usuario en MySpace.';
$txt['smi_twitter_title'] = 'Twitter';
$txt['smi_twitter_desc'] = 'Su Usuario en Twitter.';
$txt['smi_youtube_title'] = 'Youtube';
$txt['smi_youtube_desc'] = 'Su Usuario en YouTube.';
$txt['smi_deviantart_title'] = 'DeviantArt';
$txt['smi_deviantart_desc'] = 'Su Usuario en DevianArt.';
$txt['smi_pinterest_title'] = 'Pinterest';
$txt['smi_pinterest_desc'] = 'Su Usuario en Pinterest.';
$txt['smi_googleplus_title'] = 'Google+';
$txt['smi_googleplus_desc'] = 'Su Numero de ID en Google+.';
$txt['smi_buddies_title'] = 'Redes Sociales';

pastorvictor

Thank you very much, hcfwesker! I guess none of the above got added to the Spanish file, so I just replaced the English file and now everything's in Spanish. Again, great mod!

FragaCampos

Hi again,hcfwesker. .
I discovered today that these tips you gave me have a small problem.

When I try to order the columns in memberslist, I get the following error:
The database value you're trying to insert does not exist: sort

Also, my error logs have these errors when I try to sort any of the columns from this mod:
The database value you're trying to insert does not exist: sort
Function: MLAll


And it does the 8: Undefined index for every social media, like "8: Undefined index: facebook"

Any chance to get this corrected?
Thanks.

hcfwesker

#213
Quote from: FragaCampos on February 16, 2013, 01:07:33 PMWhen I try to order the columns in memberslist, I get the following error:
The database value you're trying to insert does not exist: sort

I just gave codes to display them, didn't honestly think someone would goto the MemberList to organize members by their social media. Normally people would just get it from their post or profile lol.  But try this.

Sources/Memberlist.php

Find
'msn' => array(
'down' => 'LENGTH(mem.msn) > 0 ASC, IFNULL(mem.msn, 1=1) DESC, mem.msn DESC',
'up' => 'LENGTH(mem.msn) > 0 DESC, IFNULL(mem.msn, 1=1) ASC, mem.msn ASC'
),


Just copy that code set and paste directly under it, and replace 'msn' with 'facebook' , etc.  Do this for each social media icon you allow to be displayed. these are the exact phrase for each you'll replace 'msn' with for each set you add:  'facebook', 'myspace', 'twitter', 'googleplus', 'linkedin', 'youtube', 'deviantart', 'pinterest'

Ex.
'facebook' => array(
'down' => 'LENGTH(mem.facebook) > 0 ASC, IFNULL(mem.facebook, 1=1) DESC, mem.facebook DESC',
'up' => 'LENGTH(mem.facebook) > 0 DESC, IFNULL(mem.facebook, 1=1) ASC, mem.facebook ASC'
),


The Find
if (in_array('messenger', $_POST['fields']) && (!$user_info['is_guest'] || empty($modSettings['guest_hideContacts'])))
$fields += array(3 => 'msn', 'aim', 'icq', 'yim');


Replace with
if (in_array('messenger', $_POST['fields']) && (!$user_info['is_guest'] || empty($modSettings['guest_hideContacts'])))
$fields += array(3 => 'msn', 'aim', 'icq', 'yim', 'facebook', 'myspace', 'twitter', 'googleplus', 'linkedin', 'youtube', 'deviantart', 'pinterest');




Haven't tested this, but seems to follow the same edits I did this for for Google+ and Skype in my other MOD, so should basically be the same.


FragaCampos


hcfwesker

Quote from: Conay on August 21, 2012, 12:52:28 PMThanks for your response. You've hit the nail on the head :) My FF.net field looks all lonely and out of place on my forum profile edit page.

Although I didn't know that was possible. I'll try having a go later.

Just curious, were you able to get this to work?  I'm working on an option for admins to create their own social media add-ons to the MOD, which will display along side the default icons.  Right now I'm just running into issues with the custom social icons interferring with the custom profiles when both are displaying.

But for the time being I do have a work around if you wanted to get your fanfiction icon with the others.  Just not sure if you're still around, or if you got it to work yourself.

Bob Perry of Web Presence Consulting

Quote from: hcfwesker on February 19, 2013, 01:56:41 AM
Quote from: Conay on August 21, 2012, 12:52:28 PMThanks for your response. You've hit the nail on the head :) My FF.net field looks all lonely and out of place on my forum profile edit page.

Although I didn't know that was possible. I'll try having a go later.

Just curious, were you able to get this to work?  I'm working on an option for admins to create their own social media add-ons to the MOD, which will display along side the default icons.  Right now I'm just running into issues with the custom social icons interferring with the custom profiles when both are displaying.

But for the time being I do have a work around if you wanted to get your fanfiction icon with the others.  Just not sure if you're still around, or if you got it to work yourself.

Dude, not sure about that guy's customizing, but I just completed a bullet proof hack to the Stats page that I mentioned to you previously, come take a peek you may be impressed, man I got a schooling on how to manipulate arrays in PHP but then again, I've always been easily confused by them even back in my hey-days of IBM business system programming in the Cobol & RPG languages... thought I was never going to get it functioning properly, stand by for other hacks to that page relating to other mods as well... can ya dig it?
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Arantor

Putting aside the fact that the forums page links to action=sts not action=stats and there's this randomly in the stats template:

//
// WPC Custom Hack begin... (the last "bullet proof" edit completed & posted on (Sun 02/17/2013), stand by for new additions to follow as my free time permits)
//


this is interesting.

I'm curious, what was the query used? I know it's the stats page but I'm still curious as to the query in case there's a faster way of doing it. (Unlikely, though)

Bob Perry of Web Presence Consulting

Quote from: Arantor on February 19, 2013, 08:00:16 AM
Putting aside the fact that the forums page links to action=sts not action=stats and there's this randomly in the stats template:

//
// WPC Custom Hack begin... (the last "bullet proof" edit completed & posted on (Sun 02/17/2013), stand by for new additions to follow as my free time permits)
//


this is interesting.

I'm curious, what was the query used? I know it's the stats page but I'm still curious as to the query in case there's a faster way of doing it. (Unlikely, though)

OH man, thanks for pointing out that action=sts thing, I musta missed it when I was redoing what I had messed up a while back, I had switched over to using https:// in my primary site address and that was interfering with being able to navigate to my ISP provided statistical page which was located in a subdirectory of my root named /stats, so I was playing with the links and soon discovered that although kinda cool, caused too many problems with navigating to various parts of the system and changed the primary url back to http:// and I missed changing that link back...

Yea a youngster like you may be able to show me a more elegant or streamlined way to do it my SQL skills are rusty...


// Popular Social Icons - female

$icon_result1 = $smcFunc['db_query']('', '
SELECT gender, icq, aim, yim, msn, facebook, myspace, twitter, youtube, deviantart, googleplus, linkedin, pinterest
FROM {db_prefix}members
WHERE id_group >= {int:activity} && gender = 2',
array(
'activity' => 0,
)
);
$context['top_icons_female'] = array();

while ($row_members = $smcFunc['db_fetch_assoc']($icon_result1))
{
$total_members_f = $total_members_f + 1;
$possible_hits_f = $possible_hits_f + 12;

$context['top_icons_female'][] = array(
'icq_hits_f' => $row_members['icq'],
'aim_hits_f' => $row_members['aim'],
'yim_hits_f' => $row_members['yim'],
'msn_hits_f' => $row_members['msn'],
'facebook_hits_f' => $row_members['facebook'],
'myspace_hits_f' => $row_members['myspace'],
'twitter_hits_f' => $row_members['twitter'],
'youtube_hits_f' => $row_members['youtube'],
'deviantart_hits_f' => $row_members['deviantart'],
'googleplus_hits_f' => $row_members['googleplus'],
'linkedin_hits_f' => $row_members['linkedin'],
'pinterest_hits_f' => $row_members['pinterest'],
);

if (!empty($row_members['icq']))
{
$total_hits_f = $total_hits_f + 1;
$icq_hits1 = $icq_hits1 + 1;
}
else
{
}

if (!empty($row_members['aim']))
{
$total_hits_f = $total_hits_f + 1;
$aim_hits1 = $aim_hits1 + 1;
}
else
{
}
etc., etc.


Yea I actually put that WPC blurb in there by mistake at first, but decided to leave it there and expanded on it later, actually nothing related to coding these days is bullet proof as far as I know, that's why I put it in quotes because its a relative slang term...
Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Arantor

QuoteYea a youngster like you

I'm 30 this year.

Here's how I'd do it. First up, smf_members has no indexes on any of those fields, not even gender. The only field it has an index on is id_group, but you're checking it is >= 0 - but it's an unsigned field, so it can't ever be anything else.

So, anyway. Going through to filter on gender means it still has to evaluate every row (something it would do even if there were an index due to the low selectivity of that index; it can only have 3 values, 0, 1 or 2 and no index is going to be that useful on it)

So what we might as well do is have a single query that is comparable to either of two queries, and post-process it in PHP.

I haven't tested this, but here's what I'd do.

$context['top_icons_female'] = $context['top_icons_male'] = array(
'icq' => 0,
'aim' => 0,
'yim' => 0,
'msn' => 0,
'facebook' => 0,
'myspace' => 0,
'twitter' => 0,
'youtube' => 0,
'deviantart' => 0,
'googleplsus' => 0,
'linkedin' => 0,
'pinterest' => 0,
);
$context['total_hits_female'] = $context['total_hits_male'] = 0;

$request = $smcFunc['db_query']('', '
SELECT gender, icq, aim, yim, msn, facebook, myspace, twitter, youtube, deviantart, googleplsus, linkedin, pinterest
FROM {db_prefix}members
WHERE gender > {int:no_gender}',
array(
'no_gender' => 0,
)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$gender = $row['gender'] == 1 ? 'male' : 'female';
unset ($row['gender']);
foreach ($row as $column => $value)
if (!empty($value))
{
$context['total_hits_' . $gender]++;
$context['top_icons_' . $gender][$column]++;
}
}
$smcFunc['db_free_result']($request);


The first part sets up default counts for each of the column types. The second gets everything, excluding all non-gender cases. If you want that, that's achievable but we'll deal with that separately.

Then we just get each row. We process the gender column, converting it from a number to the gender by name (1 = male, 2 = female) so we can refer to the right $context variables easily.

Then we dump that column and just step through all the rest of the columns, if they're empty() they contain nothing, otherwise we pick the right column of the right gender count and add one.

We don't need to actually store that data or anything, we just need to keep score of what ones we have, and if we have one, add one to the total hits as well as the per-field hits.

So, we have $context['total_hits_female'] and $context['total_hits_male'] for the total number of field values stored for male/female, and $context['top_icons_male']['icq'], $context['top_icons_male']['aim'] etc for the actual values.

I'm not sure where this 'possible' value is coming from for possible hits, though.

Advertisement: