Volodymyr Osypov blog

April 24, 2008

Linkedin.com field mod for SMF (part 2)

Filed under: SMF — Tags: , , — admin @ 8:49 pm

Let’s improve our LinkedIn mod, created in previous article. We will add LinkedIn column to the Members page. As you can see you can sort members list by fields like MSN, AIM, ICQ, but our mod won’t do this. We’ll just add a column with the link to LinkedIn.com profile of each user.

As you remember we define all changes, which our mod makes in modification.xml file.

Let’s add some new lines.

Memebers list template is in Memberslist.template.php

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for column which displays user’s icq –>
<search position=”after”><![CDATA[<td class=”windowbg2″>’, $member[’icq’][’link’], ‘</td>]]></search>
<!– And add our column with LinkedIn icon –>
<add>
<![CDATA[
<td class=”windowbg2″>’;
if (!empty($member[’options’][’linkedin’])) echo ‘<a href=”http://www.linkedin.com/’, $member[’options’][’linkedin’], ‘” target=”_blank”><img border=”0″ src=”‘ . $settings[’images_url’] . ‘/linkedin.gif”></a>’;
echo ‘</td>’;
echo ‘]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”before”><![CDATA[foreach ($context[’members’] as $member)]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add>
<![CDATA[ { ]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”before”><![CDATA[ <td class=”windowbg” width=”100″ align=”left”>
‘, $member[’posts’] > 0 ? ‘<img src=”‘ . $settings[’images_url’] . ‘/bar.gif” width=”‘ . $member[’post_percent’] . ‘” height=”15″ alt=”" />’ : ”, ‘
</td>
</tr>’;
}]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add>
<![CDATA[
} ]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– now search for the place where we display table columns titles (header of the table) –>
<search position=”before”><![CDATA[// We’re not able (through the template) to sort the search results right now…]]></search>
<!– If it’s ICQ column header then we add before it our cell with LinkedIn text –>
<add>
<![CDATA[
if (strpos($column[’href’],”sort=ICQ”)) {
echo ‘<td style=”width: auto;”>LinkedIn</td>’;
}
]]></add>
</operation>
</file>

<!– Now our table is one column wider as it was, so we need to fix colspan for cells which output Pages and search letters (was 12 now 13) –>
<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”replace”><![CDATA[<td colspan=”12″>]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add><![CDATA[<td colspan=”13″>]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”replace”><![CDATA[<td colspan=”12″ class=”‘, empty($settings[’use_tabs’]) ? ‘catbg’ : ‘titlebg’, ‘”>’;]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add><![CDATA[<td colspan=”13″ class=”‘, empty($settings[’use_tabs’]) ? ‘catbg’ : ‘titlebg’, ‘”>’;]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”replace”><![CDATA[<td colspan=”12″ class=”windowbg”>]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add><![CDATA[<td colspan=”13″ class=”windowbg”>]]></add>
</operation>
</file>

<file name=”$themedir/Memberlist.template.php”>
<!– A seach operation, with search rules and code to modify the file with. –>
<operation>
<!– Search for this text before the code we add. You can also search for after, and the end of the file. –>
<search position=”replace”><![CDATA[<td class=”titlebg” colspan=”12″>]]></search>
<!– Add this text when we find it. Note that it’s on it’s own line on purpose, and the CDATA keeps things clean. –>
<add><![CDATA[<td class=”titlebg” colspan=”13″>]]></add>
</operation>
</file>
OK, our mod is ready. Just pack all files in archive (I prefer tar.gz) and install through your SMF Admin interface.

1 Comment »

  1. […] previous article we improved our Linkedin.com mod for SMF. But I doubt each user will go to his/her profile page and […]

    Pingback by Volodymyr Osypov blog » Linkedin.com field mod for SMF (part 3) — April 25, 2008 @ 9:50 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress