Step 3. Modify generated code to fit your needs
Folder Structure
tamsi
├── app
│ ├── controller
│ ├── model
│ └── view
├── composer.json
├── config
│ ├── Config.php
│ ├── database.cfg.php
│ ├── database.cfg.php.gahum
│ ├── main.cfg.php
│ ├── paths.cfg.php
│ ├── security.cfg.php
│ └── views.cfg.php
├── lib
│ └── vendor
├── public_html
│ ├── Admin.dir
│ ├── advance.pub.hid.htm
│ ├── contact_us.php
│ ├── css
│ ├── home.pub.hid.php
│ ├── images
│ ├── img
│ ├── index.php
│ ├── js
│ ├── lib
│ ├── menu.hid.php
│ ├── notice.pub.hid.php
│ └── register_user.pub.hid.php
├── tamsi
│ ├── controller
│ ├── Core.php
│ ├── generate.php
│ ├── graphics.php
│ ├── model
│ ├── polygon.php
│ ├── Tamsi.php
│ └── view
├── usr
│ ├── controller
│ ├── model
│ └── view
└── usr_generated
├── controller
├── model
└── view
Rules which files should be edited
1) Files from index.php down to the images are the files that can be edited
2) Foldes from img,usr_generated,tamsi and util should not be edited
3) usr_generated are files automatically generated by the utilities which will be discussed later.
Modify Basic Structure of Page
The index.php determines the basic structure of the page. You can basically placed tamsi in any html theme structure.
Quick Summary of Process to Integrate Tamsi into a theme index.php
1. Call the core tamsi files and instatiate core objects on top of the file
2. Call the tamsi framework to load css/jquery inside the header section of the html
3. Configure menu based on login conditions
4. Render hidden login form and notice form after the menu section
5. Prepare the div.page where to display the dynamically loaded pages
6. Call display controller and all other javascript before the end marker of the html body section.
A very simple structure is shown below:
Detailed Process to Integrate Tamsi into a theme index.php
1) You must insert the following on the top most part of the index.php the calls of tamsi core files
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
require_once 'tamsi/Tamsi.php';
$tamsi = new Tamsi();
$user= new User()//Optional if you need User object to test for login status;
$role= new Role()//Optional if you need to check roles;
?>
2) You must insert the following right befor end of head section </head>
3) You may have to include the default login and notice form right after the headers, but you could also make your own
4) You may override some menus like
<ul class="nav-menu">
<li class="menu-active"><a href="#hero">Home</a></li>
<?php
if (!$role->isUserLoggedIn())
{
?>
<li class="dropdown"> <a data-toggle="dropdown" href="#" onclick="showLogin()" ><i class="fa fa-user-plus"></i> LOGIN</a></li>
<?php
} else
{
?>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Informations.dir/List Informations.rest.php">Informations</a></li>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Users.dir/List Users.rest.php">Users</a></li>
<li><a href="?command=logout" class="" style=""><i class="fa fa-user-times"></i>LOGOUT</a></li>
<?php
}?>
</ul>
5) You must insert this code inside the div.page where you need to load dynamically loaded pages. The else portion is the default home page like /home1.php
<ul class="nav-menu">
<li class="menu-active"><a href="#hero">Home</a></li>
<?php
if (!$role->isUserLoggedIn())
{
?>
<li class="dropdown"> <a data-toggle="dropdown" href="#" onclick="showLogin()" ><i class="fa fa-user-plus"></i> LOGIN</a></li>
<?php
} else
{
?>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Informations.dir/List Informations.rest.php">Informations</a></li>
<li><a href="#" class="mx-" mx-container="div.page" mx-click="?command=display_rest&path=Admin.dir/Users.dir/List Users.rest.php">Users</a></li>
<li><a href="?command=logout" class="" style=""><i class="fa fa-user-times"></i>LOGOUT</a></li>
<?php
}?>
</ul>
6. All other js files should be called at the end of the html before the </body> as shown below
<?php $tamsi->view->initializeScripts(array("mathjax"=>false,"speak"=>false,"chosen"=>true,"wysiwyg"=>true,"datetimepicker"=>true));?>
The resulting integration of Tamsi into a more complex theme index.php is shown below:
9) All php codes marked by
<?php ....?>
are required
10) There should always be a
<div class='page'> </div>
because this is where other pages are loaded via restful process.
Modify Models
1) You should only modify the extended versions of models at usr/model folder. This is to insure that when you change your db and update your models
the changes you added will not be overwritten by generaModel.php. The generateModel.php will only overwrite the models at usr_generate/model folders
2) You may override functions from the usr_generated/model folder
3) You should add user functions only to the models at usr/model folder.
Modify Controllers
1) You should only modify the extended versions of controllers at usr/controller folder. This is to insure that when you change your db and update your controllers the changes you added will not be overwritten by generaController.php. The generateController.php will only overwrite the controllers at usr_generate/model folders
2) You may override functions from the usr_generated/controller folder
3) You should add user controller functions only to the controllers at usr/controller folder.
Modify Views
1) Views (List, Edit, New) and View models are automatically generated at usr_generated/view folder by generateView.php.
2) generateView.php also places a default extensions of view models and files at usr/views if not yet available. This is the portion that you can edit.
3) generateView.php also places a default file at the Administration directory for listing, adding and editing of table items. These views simple include the views at usr/view/.
The above is terminal command in linux that assumes the folder structure defined above executed at ../Admin.dir/Users.dir/ directory