Skip to content

Create A Blank Application

dongbeta edited this page Jul 29, 2011 · 1 revision

Knowing how to create a blank application for Xoops Engine is sometimes usefully.

Create Directories

XoopsEngine/usr/apps/demo

  • blocks contains the class files of blocks
  • class contains library
  • configs contains configuration files
  • controllers contains controller class files
  • languages contains languages pack
  • models contains model class files
  • resources contains static files, such as images and javascript files. this folder will be copied to htdocs when the appliction being installed
  • sql contains mysql files
  • templates contains template files, html.

Create Necessary Files

To be a application, some files is necessary.

Create Application Information File

The file called application information file is put at directory configs and named as info.php. The basic content as follow, you don't need know the meaning, other wiki page will descripte it.

return array(
    // App name
    'name'          => _DEMO_MI_NAME,
    // Description, for admin
    'description'   => _DEMO_MI_DESC,
    // Version number
    'version'       => '1.0.0',
    // Author: full name <email> <website>
    'author'        => 'Your Name <[email protected]>',
    // Contact email
    'email'         => '[email protected]',
    // Credits for contributors
    'credits'       => 'XOOPS Development Team; Zend Framework',
    // Distribution license
    'license'       => 'GPL v2',
    // Logo image, for admin
    'logo'          => 'resources/images/logo.png',
    // Readme file, for admin
    'readme'        => 'docs/readme.txt',
);

The info.php contains the data about application configuration. The above is not the entire data but to let this demo application run.

Create A Default Controller

The Xoops Engine applications are based on MVC. So, one application must contains on default controller named _{application name}IndexController . The follow is the default controller for the application demo.

class Demo_IndexController extends Xoops_Zend_Controller_Action
{
    public function indexAction()
    {
        $this->template->assign('sayhi', 'Hi, Xoops!');
    }
}

Create Template for Default Controller

Corresponding to the default controller, the template file is index_index.html and put at /usr/apps/demo/tamplates/.

<h1><{$sayhi}></h1>

Let's Rock!

Now, you can start the work of creating.