Controllers, Views & Themes

Controllers

Appzio provides you with a lot of pre-made components that you can use or build on top of. We call those components “actions” and their logic is declared by controllers.Controllers are the glue between the database and the client. We use them to query information and send commands to render elements on the device. Most controllers are prefixed with “Mobile” followed by an identifier of their function. For example – MobilematchingController, MobileregisterController, MobileuserprofileController. Their purpose is to provide you with the basic functionality of our platform that is then to be extended or modified.

We understand that every application has it’s specific business logic and requires personalization. This can be done easily with Appzio with basic Object Oriented Programming knowledge. You can extend, modify and create new logic by using core programming concepts such as abstraction and polymorphism.

Themes

One of the main benefits of developing with Appzio is speed. You can use pre-made actions for the core functionality and extend them using themes in order to provide the application specific logic. Every action contains a themes folder in which you can do that by creating a folder and naming it with the name of your theme. If you check the admin dashboard you will see that in your action’s 

When creating a new application what you will most likely do is create the basic structure of your app using the pre-made components and then create your themes for each one in order to replace images, styles and extend their functionality. This way you get good code separation for each one of your apps.

Most themes consist of three folders – controllers, images and styles

Overriding Controllers

In the controllers folder of your theme you can create your own controller that should extend the base action’s controller. If our theme is called appzio and we want to extend the functionality of the matching action we should name our controller like this:

class MobilematchingAppzioController extends MobilematchingController

The only requirement is that you follow the following naming convention – [Actionname][Theme][Controller | View]
. Your file should have the same name. Now whenever this action is to be executed, the platform will first go into your class, so you can override the available methods and create your own. There is no requirement for declaring methods or any other configuration

Theme Images

Once you have selected your custom theme from the admin. The platform will be looking for any of the required images in your theme’s directory. If you change your theme and then refresh the app you will most likely see the “Image not found” message everywhere. Make sure you have replaced the necessary images or copied those that you will need from the main action’s folder.

Theme Styles

If you want to override the theme’s styles you must create a JSON file containing all of the style attributes and values in your theme’s styles directory. It should use the following naming convention – [Action Name].json. Using the previous example with the matching action, our styles file should be named Mobilematching.json. In your controller you can redefine the layout of the action and use styles that you find suitable.

Views

Views are a new addition to the Appzio platform and are used to achieve better separation between the functionality and the presentational logic. Using views is always preferred to controllers and you should try to maintain a good split between both. The main entry point for the platform is the view and you should keep the convention to use it only for rendering logic.

Views can also be themed thus providing a way for extension and modification. Theme names follow the controller theming convention of  [Actionname][Theme][Controller | View]

Example

class MobileloginAppzioView extends MobileloginAppzioController
{
    ...
}

Views & Styles

You can write inline styles in view files and these will automatically get added to style sheet and stripped from the actual layout code. This will decrease the size of the payload we are sending to client. These auto generated styles can’t be edited anywhere since they are temporary. They are also user specific, so using users screen and environment variables works, but only with mobile clients released after 13th of June 2017.

Controllers & associated actions