How to write a simple component for Ossn


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/


The ossncom.php file is the control hub of any component.
Create ossn
com.php file, example : components/newcomponent/ossncom.php


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');


To register languages in your component create a directory /locale in your component folder. The language file name must be like ossnisolang_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); 


Create ossn_com.xml in components/new_component/ the code should look like :

<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="">
    <name>This is my componennt</name>
    <author>Author Name</author>
    <description>Description of my component.</description>
    <license>License name</license>
    <license_url>License URL</license_url>
    <version>Version of component</version>

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

  • The directory must not contain any special characters
  • Blank spaces are not allowed


Create a zip archive of the directory of your component. Make sure that on opening your archive it will appears as newcomponent/ossncom.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.


After installation you can also change component files manually using ftp

See the Hello World component

Arsalan Shah