Navigation:  "The Jet Engine" PHP Application Framework > Creating a Jet Engine Application > Required Files >

plugins.php

Previous pageReturn to chapter overviewNext page

plugins.php

 

This is your plugins / output module.

 

The plugins module contains specifically named functions that match up to any <!-- PLUGIN: .. --> tags that you may have in your templates.  As you'll recall from the section on templates, the iTemplate system will parse your HTML Templates looking for these plugin tags, and will replace those tags with the return value of functions in this file that bear those same names.

 

i.e. <!-- PLUGIN:BODY --> will look for a function called body() in this plugins.php file.  (note that plugin names are not case sensitive)

 

A note on "PLUGIN:BODY" ... we typically use that plugin as the "main output" for our program --- the main body of our template.  Since a program can potentially do a hundred different things, like draw forms, take the submissions, print out articles, etc ... we design all of our internal applications with a body() function that does nothing on it's own, but instead sends back the main output of the program, from the application module.  This output is automatically generated by the core system when the program fires up.   All you need to do in the body plugin is "return" it to the template parser.

 

An well commented example is given below.   In this example, the body() function, just like we do in the UNREGISTERED EVALUATION VERSION and application.php modules,  branches out and does specific tasks depending on what the "action" was ... "action" being a query string paramater that was specified in the URL or from a form submission.  This plugins module does generate HTML, but it does not output it in any way.  Rather, your funtions must return the HTML that you want displayed as they run.

 

 


 

<?php

 

  /*

     ================================================================================

     <!-- PLUGIN:BODY -->

 

     This plugin does the lions share of the work, outputting the main content of

     your application, based on the users' actions

     ================================================================================

  */

       function body() {

 

          global $controllerObject;

 

          return $controllerObject->output;

 

       }

 

 

 

  /*

     ================================================================================

     <!-- PLUGIN:TITLE -->

 

     This plugin does the lions share of the work, outputting the main content of

     your application, based on the users' actions

     ================================================================================

  */

       function title() {

 

          global $controllerObject;

 

          return $controllerObject->title;

 

          if ( $controllerObject->blog_post ) {

              return "My Blog" . $controllerObject->blog_post['title'];

          }

 

       }

 

 

 

 

  /*

     ================================================================================

     <!-- PLUGIN:BLOG_POSTS -->

 

     This retuns a list of links to all blog articles, sorted by date.

     ================================================================================

  */

 

       // Home Page: Shows all blog posts;

       function blog_posts() {

 

           global $controllerObject;

           global $config;

           global $jet;

 

           $list = '';

 

           if ( $controllerObject->articles ) {

 

               $list = "<b>Blog Posts</b><br />";

             

               foreach ( $controllerObject->articles as $article ) {

                   $date = date("m/d/Y", $article['post_date']);

 

                   $url = $jet->dynamic_url(

                       array(

                         "controller"=>"blog",

                         "action"=>"article",

                         "article_id"=>$article['rowid']

                       ),

                       $config['url_format']

                   );

 

                   $list .= "

                      <div style='padding-left:8px'><a href='$url'>$article[title]</a> ($date)</div>

                   ";

               }

           }

 

           return $list;

 

       }

 

 

 

?>


This help file was created with an unregistered evaluation copy of Help & Manual. © EC Software. All rights reserved. This message will not appear if you compile this help file with the registered version of Help & Manual.