Hi There
I have been "Cooking" for a while now and have many split projects and links to other components... just thought i would share an easy way to split projects and access data from tables belonging to your Cook Projects (can also be adapted for other components)
Firstly I must say that many of my larger projects will build without issues in Cook 2.5 - A major improvement over the early days Thanks admin
From the early days i soon found that splitting projects assists in "manageability" of large scale projects. (Yes there is overheads such as duplicated code...)
With a little careful planning splitting projects becomes easy but before we start we must take in depth look at how Cook tables are generated for each project.
Case Study: A Large Scale Retailer
This retailer has a head office, a warehouse, and serveral shop outlets
Their user interface has been build with Cook Self Service
Their data source and user interface is hosted on a single server somewhere in the big www cloud.
Along with this they plan to sell products on the internet at a later date
Data Lists and Tables |
Warehouse: needs access to
suppliers list
warehouse inventory list
warehouse storage location list
employees list
shop list
.....
..... | Head office: needs access to
suppliers list
warehouse inventory list
accounts list
shop sales records
employees lists
shop list
item price lists
.....
..... | Shop outlets: needs access to
item price list
shop sales records
employees list
warehouse inventory list
.....
..... |
For manageability four projects have been created using Cook Self Service
another project will soon be created for online sales
From the above we can see that a number of tables are common to some or all projects so lets start thinking about split projects
The project group has a common name - Retailer
The head office project name will be - Retailer HeadOffice
The warehouse project name will be - Retailer Warehouse
The shop outlet project will be called - Retailer Shopoutlet
The fourth project contains data tables "common" to all projects and will be called Retailer
Lets look at the project table names and how they are created by the Cook Builder in each project
Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets
Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_headofficeemployees
shop outlets - retailler_headofficeshopoutlets
Retailer Warehouse => table name
employees - retailer_warehouseemployees
shop outlets - retailer_warehouseshopoutlets
warehouse Inventory - retailer_warehousewarehouseinventory
shopoutlet Inventory - retailer_warehouseshopoutletinventory
So how do we link all these tables to read from the same data tables?
simple - add an extra "trim marker" to the table alias in the right "spot"
in this case the "trim marker" will be "exttbl"
the exttbl "trim marker" is added to all tables that are external to the project
Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets
Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_headoffice
exttblemployees
shop outlets - retailler_headoffice
exttblshopoutlets
warehouse inventory - retailer_headoffice
exttblwarehouseinventory
shopoutlet inventory - retailer_headoffice
exttblshopoutletinventory
Retailer Warehouse => table name
employees - retailer_warehouse
exttblemployees
shop outlets - retailer_warehouse
exttblshopoutlets
warehouse inventory - retailer_warehouse
exttblwarehouseinventory
shopoutlet inventory - retailer_warehouse
exttblshopoutletinventory
Note: The warehouse inventory example above shows is a special case where the warehouse inventory table will technically be an "internal" table of retailer warehouse
An Example -
want to add a separate table for warehouse employees to perhaps hold more data than the employees table? Simply create the table and put the "trim marker" here... warehouse employees - retailer_warehouse
exttblwarehouseemployees
So now what do we need to do?
- download your project
- extract the project zip file
- Adjust your MySQL install and un-install files
- perform a simple search and replace on the whole project folder and sub folders - site, admin ...
- its just one string in the format #__projectgroup_projectnameexttbl replaced by #__projectgroup_
- Zip your project
- Upload and install
Heres How
Adjust your MySQL install and un-install files: admin\sql\install.mysql.utf8.sql and admin\sql\uninstall.mysql.utf8.sql
I usually do this first before any search and replace - makes it easier to make sure all external tables are not deleted by accident when un-installing a project that links to the main table of another project
in the MySQL install file
- delete or comment out the create table statement for all "external" tables that contain the trim marker "exttbl"
- remove the just the "extbl" trim maker from the create table statement for "internal" tables
- see note above in retail_warehouse to understand "internal" and "external" tables
in the MySQL uninstall file
- delete or comment out the drop table statement for all "external" tables that names contain the trim marker "exttbl"
- remove the "extbl" trim maker from the drop table statement for "internal" tables
- see note above in retail_warehouse to understand "internal" and "external" tables
Search and Replace
Retailer Project
Do nothing leave as is because these are the common tables
Retailer Head Office Project
Search: #__retailer_headofficeexttbl
Replace: #__retailer_
Retailer Warehouse Project
Search: #__retailer_warehouseexttbl
Replace: #__retailer_
AND FINALLY THE RESULTS!!!
Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets
Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_employees
shop outlets - retailer_shopoutlets
warehouse inventory - retailer_warehouseinventory
shopoutlet inventory - retailer_shopoutletinventory
Retailer Warehouse => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets
warehouse inventory - retailer_warehouseinventory
shopoutlet inventory - retailer_shopoutletinventory
Have you adjusted your MySQL install and uninstall files?
- Yes Great!
- No? Do it now!
Zip your project and upload
I must note that the above search and replace routine only allows you to connect to the same data table it will not load the view of the external component
additional search and replace routines (not covered here) must be done to load the view of another component
As you can see with some careful planning you can now start the retailer_online project and its easily link it to any data in all of the projects above
Happy Cooking!