Logo

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:


  • interact (this can be placed on the profile page and when a user visits another user's profile page, he/she can send different interactions)
  • interactions list (a list containing all the sent and received interactions)
  • infobar (a link that can be placed in the Info Bar to quickly access the interactions link)


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:


  • assets (backend assets: javascript files, stylesheet files, images, etc)
  • config (configuration xmls for different features of the component)
  • controllers (backend controllers)
  • models (backend models)
  • tables (addons tables)
  • views (backend views)
  • manifest.xml (installation manifest)


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:


  • Addon is the name of the addon
  • Section can be Backend or Frontend
  • Asset can be Controller, Model or View
  • Name is the name of the current asset.


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:


  • assets (frontend assets)
  • controllers (frontend controllers)
  • models (frontend models)
  • views (frontend views)




(!) Documentation based on Social Factory version 3.7.7