webCOMAND

webCOMAND Apps Tutorial

This tutorial builds on the Content Types, Packages and MVC Apps Tutorials to create a webCOMAND App.  webCOMAND Apps are launched from within webCOMAND and can take advantage of a shared environment and webCOMAND Framework.

Create "Presidents" webCOMAND App

To turn our existing package into a simple webCOMAND app:

  1. Launch the Content Manager (CMS) App.
  2. In the folder tree on the left, expand and click: / Bases / Presidents / Presidents Demo.
  3. Click Add Content (New Menu) in the Collection Bar and select "webCOMAND App" from the drop-down.
  4. Enter Title "Presidents".
  5. Enter Identifier "presidents".
  6. Select Package "Presidents Demo".
  7. Enter Summary "View and manage United States presidents."
  8. Upload Icon of United States Flag (same one used for Presidents Content Type).
  9. Click Approve and Back.

The new Presidents app should now appear last in the main Apps drop-down.

Create "app.php" PHP File

If all the app functionality we want is the webCOMAND headers and a scroll bar, then we are done.  To take advantage of the webCOMAND Framework and utilize the built in user interface components though, we need to create a class that extends webcomand_app and defines a launch method, which will be called when the app is launched.

We will add two panels for our user interface for a list of all presidents on the left and a selected president on the right.

  1. Click Add Content (New Menu) in the Collection Bar and select "PHP File" from the drop-down.
  2. Enter Filename "app.php".
  3. Enter Text:
    <?php
    namespace com_presidentsdemo_www;
    
    use com_webcomand\models\WebCOMANDApp;
    use com_webcomand\components\cpath_view;
    
    class app extends WebCOMANDApp {
        public function launch($options = []) {
            // populate LeftViewContainer with all presidents
            $this->add_component('\com_webcomand\components\cpath_view', [
                    'Container' => 'LeftViewContainer',
                    'Identifier' => 'list',
                    cpath_view::CPATH => '[:President]'
            ]);
    
            // populate CenterViewContainer with first president
            $this->add_component('\com_webcomand\components\cpath_view', [
                 'Container' => 'CenterViewContainer',
                 'Identifier' => 'form',
                 // link this view to the list above with:
                 cpath_view::PARENTS => ['list'],
                 // display first president initially
                 cpath_view::CPATH => '[:President AND Number=1]'
            ]);
        }
    }
  4. Click Approve.

Update "index.php" PHP File

Next, we need to update the package router to run the app instead of using the MVC framework.

  1. Click "PHP File" under "Presidents Demo" in the folder tree on the left.
  2. Click "index.php" on the right.
  3. Update the Text to:
    <?php
    namespace com_presidentsdemo_www;
    
    $framework = new \com_webcomand\framework();
    $framework->require_login();
    
    app::run($framework);
    
  4. Click Approve.

Update "Presidents" webCOMAND App

Finally, we need to update the webCOMAND App to specify the webCOMAND App class, so webCOMAND knows what to launch.

  1. Click "WebCOMAND Apps" under "Presidents Demo" in the folder tree on the left.
  2. Click "Presidents" on the right.
  3. Enter the Class Name "app".
  4. Click Approve.

Conclusion

The Presidents app can now be launched from the Apps drop-down.  It uses the webCOMAND Framework to display a mobile-friendly list of presidents that can be clicked to view and edit their details.