Creating a Custom Addon Tutorial


Developing an Addon for Social Factory is similar to developing a component for Joomla!. The addon implements the same MVC structure with controllers, models and views. Like the component, the addon has frontend and backend sections.


For this tutorial we'll take a look at how the Interactions addon is implemented in the Social Factory component.

What does the Interactions addon do?

  1. The Admin defines the interactions (kiss, hug, etc.) in the backend view.
  2. Users send each other the interactions on the frontend.


The addons do not have an entrypoint (like the Joomla components), so you can't access them from outside of Social Factory. To access a controller and task from the addon you'll have to use the following query string:


index.php?option=com_socialfactory&task=addon.sfexecute&sftask=ADDON.CONTROLLER.TASK.INSTANCEID


For the user to interact with your addon, you need to create instances of your addon and add them to the different pages of the component. The instances are similar to the menu items from Joomla, providing a link to your component(addon), but they can display more than just a link.


For the Interactions addon, there can be implemented several instances:



Let's take a look on the backend section. All the addon's files are stored in [Joomla dir]/components/com_socialfactory/addons/interactions folder. Here we'll find the files and folders:



The installation manifest is similar to the Joomla component manifest. Let's take a look at the manifest.xml file:


In the administration/menu section the menu links that show up on the backend are defined:


<menu>
  <item sftask="interactions" title="Interactions" />
  <item sftask="about" title="About" />
</menu>


In the administration/tasks section the instances that can be created for the addon are defined:


<tasks>
  <task sftask="interactions.interact" label="Show interactions options" />
  <task sftask="interactions.showlist" label="Show interactions list" />
  <task sftask="interactions.infobar" label="Interactions counter" infobar="true" />
</tasks>


In the administration/notifications section are defined the notifications that the addon can send:


<notifications>
  <notification type="received_interaction">Received interaction</notification>
</notifications>


For each notification defined in this section, you must create an XML configuration file (named as the notification) that contains the tokens the notification uses in [Joomla dir]\administrator\components\com_socialfactory\addons\interactions\config\notifications\received_interaction.xml


The controllers, models and view must follow the naming convention: AddonSectionSfAssetName where:



For the backend about controller of the Interactions addon, the name would be: InteractionsBackendSfControllerAbout.


On the frontend the addon files are stored in [Joomla dir]\components\com_socialfactory\addons\interactions folder. Here we'll find the folders:





(!) Documentation based on Social Factory version 3.7.7