Linkedin.com field mod for SMF
Want to create own little profile mod for SMF forums? It’s easy. Let’s do it
As example we’ll create profile mod which displays link you your Linkedin.com profile.
For mod we need 2 xml files, which define our mod and ‘images’ directory with “in” icon in it:
- package-info.xml (our package definition)
- modification.xml
- images/linkedin.gif
First we’ll create package-info.xml:
<?xml version=”1.0″?>
<!DOCTYPE package-info SYSTEM “http://www.simplemachines.org/xml/package-info”>
<!– - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is a simplified package manifest for SMF packages.
ATTENTION: If you are trying to install this manually, you should try
the package manager. If it will not work for you, please take a look
at the following for information on this format:
http://mods.simplemachines.org/docs/manual-install.php
================================================================================
This script can be used to make your package do many different things.
The following documentation should be available on the format of this
file and the things you can do with it:
http://mods.simplemachines.org/docs/package-info.php
Please see the other included file, package-info_advanced.xml, for
a more detailed description of what you can do with this file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - –>
<package-info xmlns=”http://www.simplemachines.org/xml/package-info” xmlns:smf=”http://www.simplemachines.org/”>
<!– For the id, always use something unique - put your name, a colon, and then the package name. no spaces please! –>
<id>VolodymyrOsypov:linkedinfield</id>
<!– Below should be the name of this package. –>
<name>Linkedin.com profile field</name>
<!– The version of this modification. Keep it numeric so PHP can tell that old < new. –>
<version>1.0</version>
<!– Type, one of: modification (in our case), avatar, language. –>
<type>modification</type>
<!– Installation, the key part of this file. –>
<install>
<modification>modification.xml</modification>
<require-dir name=”images” destination=”$themedir” />
</install>
<!– Don’t forget something to make it uninstallable! –>
<uninstall>
<modification reverse=”true”>modification.xml</modification>
<remove-file name=”$themedir/images/linkedin.gif” />
</uninstall>
</package-info>
Now we we’ll create the mod installation file: modification.xml:
<?xml version=”1.0″?>
<!DOCTYPE modification SYSTEM “http://www.simplemachines.org/xml/modification”>
<!– - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is an example modification file for SMF packages.
ATTENTION: If you are trying to install this manually, you should try
the package manager. If it will not work for you, please take a look
at the following for information on this format:
http://mods.simplemachines.org/docs/manual-install.php
================================================================================
Modification files can be used to modify files so that they do what
your package needs them to do to work properly.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - –>
<modification xmlns=”http://www.simplemachines.org/xml/modification” xmlns:smf=”http://www.simplemachines.org/”>
<!– ID - This information needs to be the same as that in the package-info.xml. –>
<id>VolodymyrOsypov:linkedinfield</id>
<version>1.0</version>
<!– Edit a specific file, where we’ll make changes. –>
<file name=”$themedir/Profile.template.php”>
<!– A search 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><input type=”text” name=”websiteUrl” size=”50″ value=”‘, $context[’member’][’website’][’url’], ‘” /></td>]]></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[</tr><tr>
<td><b>Linkedin.com Profile: </b></td> <td>http://www.linkedin.com/<input type=”text” name=”default_options[linkedin]” size=”24″ value=”‘, @$context[’member’][’options’][’linkedin’], ‘” /></td>
]]></add>
</operation>
<operation>
<search position=”before”><![CDATA[<td><a href=”‘, $context[’member’][’website’][’url’], ‘” target=”_blank”>’, $context[’member’][’website’][’title’], ‘</a></td>]]></search>
<add><![CDATA[</tr><tr>
‘, !empty($context[’member’][’options’][’linkedin’]) ?’</tr><tr> <td><b>Linkedin.com Profile: </b></td> <td><a href=”http://www.linkedin.com/’
. $context[’member’][’options’][’linkedin’] . ‘ “target=”_blank”>Linkedin.com Profile</a></td>’: ”, ‘
]]></add>
</operation>
</file>
<file name=”$themedir/Display.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[ // Show their personal text?
if (!empty($settings[’show_blurb’]) && $message[’member’][’blurb’] != ”)
echo ‘
‘, $message[’member’][’blurb’], ‘<br />
<br />’;]]></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[if (!empty($message[’member’][’options’][’linkedin’])) echo ‘<a href=”http://www.linkedin.com/’, $message[’member’][’options’][’linkedin’], ‘” target=”_blank”><img border=”0″ src=”‘ . $settings[’images_url’] . ‘/linkedin.gif”></a>’;
]]></add>
</operation>
</file>
</modification>
As you’ve seen we user our own defined $context[’member’][’options’][’linkedin’] and $message[’member’][’options’][’linkedin’]. You don’t need to define them elsewhere, or create fields in database.
Now we can add these files to archive and install on our SMF forum.
On profile page you will see:

This mod can be downloaded at this location.
[…] 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 […]
Pingback by Volodymyr Osypov blog » Linkedin.com field mod for SMF (part 2) — April 24, 2008 @ 8:49 pm