Module Class Page Routers

Class Routers

The Class Routers within EssenceOne are very manageable considering what all they do. Essentially they store a list of each Modules pages along with the Controllers and Views needed for each one. This allows everything within the Module to be wrapped within the class. Then the GET or POST method can then be used to handle the dynamics of your build in a way this is very simple. Unlike many Frameworks EssenceOne does everything in reverse. First it routes everything within a Module, it stages the entire program within a Class, then on demand it puts it all together for each Page.

Below we show how each Module is separated using the Alphanumeric order of m4,c4,v4, etc too distinguish to the developer where they are in the build process. A new Module here Albums in which it's class Router below is contained in the m4/ folder and all it's needed Files, Views and Controllers are located in v4 and c4/ respectively. Notice too the use of passed class_user_check.php from the Members class protected router modules files. Easy as we know it is in Module m2/ and stored user check is in the c2/ class_user_check.php directory. 

A Simple Router Class
class router_Album
{
  function routeAlbum()
  {
     include('a4/config.php');//for album related config libraries if used to pass meta, data or variables//
     include('c2/class_user_check.php);//we chech sessions user variables or redirect to login.//

     if(isset($_GET['page']))
    {
      $page = htmlspecialchars($_GET["page"]);


       if($page == 'albums')
      {
      $title='Album List';
      $metadiscription='A cool site.';
      include('v4/a1.php');
      include('v4/b1.php');
      include('v4/c1.php');
      include('c4/class_show_albums.php');//we auto include controller//
      include('v4/dalbums.php');
      include('v4/e1.php');
      include('v4/f1.php');
      }//end page//

      if($page == 'images')
      {
      $title='Album Images';
      $metadiscription='A cool site.';
      include('v4/a1.php');
      include('v4/b1.php');
      include('v4/c1.php');
      include('c4/class_show_images.php');//we auto include controller//
      include('v4/dalbums.php');
      include('v4/e1.php');
      include('v4/f1.php');
      }//end page//

      if($page == 'image_view')
      {
      $title='Single Image';
      $metadiscription='A cool site.';
      include('v4/a1.php');
      include('v4/b1.php');
      include('v4/c1.php');
      include('c4/class_show_images.php');//we auto include controller//
      include('v4/dalbums.php');
      include('v4/e1.php');
      include('v4/f1.php');
      }//end page//

    } else {

      $title='Album List';
      $metadiscription='A cool site.';
      include('v4/a1.php');
      include('v4/b1.php');
      include('v4/c1.php');
      include('c4/class_show_albums.php');//we auto include controller//
      include('v4/dalbums.php');
      include('v4/e1.php');
      include('v4/f1.php');

    }//end else page//










    }//end if set//
  }//end function//
}//end class//  

No comments:

Post a Comment