Basics
Every OSSN component is located in a subdirectory of the /components
folder and contains a PHP script called ossn_com.php
. The name of your subdirectory will be your component name, so choose it carefully! It should be unique but readable, so that site administrators don't accidentally overwrite it with another component, but they can also understand at a glance what your component does.
Example: components/new_component/
ossn_com.php
The ossn_com.php
file is the control hub of any component.
Create ossn_com.php
file, example : components/new_component/ossn_com.php
Initialization
We recommend that you use the following skeleton code in your ossn_com.php
file:
function my_new_component(){
pages, actions, menus
}
ossn_register_callback('ossn', 'init', 'my_new_component');
Languages
To register languages in your component create a directory /locale
in your component folder. The language file name must be like ossn_iso_lang_code.php
example components/new_component/locale/ossn.en.php
for English translation
The language code is ISO 639-1 standard language code.
Use following code in language file:
$en = array(
'hello:world' => 'Hello World!',
);
ossn_register_languages('en', $en);
ossn_com.xml
Create ossn_com.xml
in components/new_component/
the code should look like :
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.opensource-socialnetwork.org/v/3.0">
<name>This is my componennt</name>
<id>new_component</id>
<author>Author Name</author>
<description>Description of my component.</description>
<license>License name</license>
<author_url>http://www.authorurl.com</author_url>
<license_url>License URL</license_url>
<version>Version of component</version>
<requires>
<type>ossn_version</type>
<version>4.0</version>
</requires>
</component>
Here the id is the exact path where components files resides, 'new_component' is the correct path, so the component directory appear as /components/[ID]/ossn_com.php
Component ID/directory convention
Pack
Create a zip archive of the directory of your component. Make sure that on opening your archive it will appears as new_component/ossn_com.php
By using the Component installer you can upload your component to the server and make it part of your Ossn installation after clicking "Enable" in the Components section of your admin panel.
Changes
After installation you can also change component files manually using ftp
See the Hello World component https://github.com/opensource-socialnetwork/HelloWorld
Thanks
Arsalan Shah