History of Tutorial_Custom_Package
Version 22 | Current version | |||||
---|---|---|---|---|---|---|
IntroductionThis is a BASIC tutorial that will show you how to make a quick package that loops through a table and displays its data. I wrote this because I am starting from the VERY beginning here in bitweaver, and want to make tutorials as I go to help new opensource developers who are joining the project and need a booster seat to sit at the table! I hope it is useful to you!Thanks for your help Spiderr 1) Create a New bitweaverPackage
$ mkdir newPackage/modules $ mkdir newPackage/templates{CODE} 2) Create your table
CREATE TABLE test_table ( test_table_id int NOT NULL, memo text[] ) WITHOUT OIDS; -- -- This CREATE TABLE statement works for MySQL and MSSQL CREATE TABLE test_table ( test_table_id int NOT NULL, memo text ) {CODE} Insert several rows into the table. {CODE()}--These INSERT statements work for postgreSQL, MySQL and MSSQL INSERT INTO test_table (test_table_id, memo) VALUES (1, 'The first memo' ); INSERT INTO test_table (test_table_id, memo) VALUES (2, 'The second memo' ); INSERT INTO test_table (test_table_id, memo) VALUES (3, 'The third memo' );{CODE} 3) Create your PHP file
require_once('../bit_setup_inc.php'); //initialized the entire system! $result = $gBitDb->query("SELECT * FROM test_table"); $gBitSmarty->assign('test_table', $result->GetArray()); $gBitSystem->display( NEWPACKAGE_PKG_PATH . '/templates/newPackage.tpl', 'New Package Page' ); ?>{CODE} 4) Create your package's bit_setup_inc file
global $gBitSystem; $gBitSystem->registerPackage( 'newPackage', dirname( FILE ).'/' ); if( $gBitSystem->isPackageActive( 'newPackage' ) ) { // ... maybe do some initialization stuff if your package is turned on } ?>{CODE} 5) Create your Smarty TPL file
6) Activate your new package
Voila!Go to http://yourbitweaverURL/newPackage/ and your table should be displayed!7) Now, create a Module
(:exclaim:) $smart.const.whatever_PKG_URL is a pointer to a folder called whatever in the root... to use icons check out our cool new icon system called biticon 8) List of available constants in bitweaver<package>_PKG_PATH --> example: WIKI_PKG_PATH this will give you the full path to the wiki folder <package>_PKG_URL --> example: WIKI_PKG_URL this will give you the full url to the wiki folder these contain the full path and url to the root of the application BIT_ROOT_PATH BIT_ROOT_URL contains the name of the currently active package ACTIVE_PACKAGE full path and url to the currently active style THEMES_STYLE_PATH THEMES_STYLE_URL Stay tuned for more Tutorials! Fire 9)Make the package installableIn order to make the package installable, you need an additional directory in newPackage/admin{CODE()}$ mkdir newPackage/admin{CODE} and the schema information to chack the database with which comes in the form of a ))schema_inc.php(( file The sample for this package is {CODE()} <?php $tables = array( 'test_table' => " test_table_id I4 NOTNULL PRIMARY, memo X ", ); global $gBitInstaller; foreach( array_keys( $tables ) AS $tableName ) { $gBitInstaller->registerSchemaTable( NEWPACKAGE_PKG_NAME, $tableName, $tables$tableName ); } $gBitInstaller->registerPackageInfo( NEWPACKAGE_PKG_NAME, array( 'description' => "A test package.", 'license' => 'LGPL', 'version' => '0.1', 'state' => 'beta', 'dependencies' => '', ) ); ?> {CODE}</package></package> | IntroductionThis is a BASIC tutorial that will show you how to make a quick package that loops through a table and displays its data. I wrote this because I am starting from the VERY beginning here in bitweaver, and want to make tutorials as I go to help new opensource developers who are joining the project and need a booster seat to sit at the table! I hope it is useful to you!Thanks for your help Spiderr 1) Create a New bitweaverPackage
2) Create your table
Insert several rows into the table.
3) Create your PHP file
4) Create your package's bit_setup_inc file
5) Create your Smarty TPL file
Bitweaver uses the Smarty template engine, enriched with some custom functions. Read more about that on Smarty Functions. 6) Activate your new package
Voila!Go to http://yourbitweaverURL/newPackage/ and your table should be displayed!7a) Now, create a Module
(:exclaim:) $smart.const.whatever_PKG_URL is a pointer to a folder called whatever in the root... to use icons check out our cool new icon system called biticon 7b) Add menu entriesMaybe you chose your package be no module. Maybe you have additional functionality that shall plugin into Bitweaver's menu bar. This is a two step procedure.First create your templates/menu_newPackage.tpl file with the menu items you want to add.
Then register the menu in bit_setup_inc.php.
To read more about menus, read ((Adding YOUR OWN dropdown menu to the Nav bar!)). 8) List of available constants in bitweaver<package>_PKG_PATH --> example: WIKI_PKG_PATH this will give you the full path to the wiki folder <package>_PKG_URL --> example: WIKI_PKG_URL this will give you the full url to the wiki folder these contain the full path and url to the root of the application BIT_ROOT_PATH BIT_ROOT_URL contains the table name prefix as given in the install script BIT_DB_PREFIX contains the name of the currently active package ACTIVE_PACKAGE full path and url to the currently active style THEMES_STYLE_PATH THEMES_STYLE_URL Stay tuned for more Tutorials! Fire 9)Make the package installableIn order to make the package installable, you need an additional directory in newPackage/admin
and the schema information to chack the database with which comes in the form of a schema_inc.php file. In case you want to create columns with other data types, see DataDict. The sample for this package is
To add a nice looking icon besides the package name, simply create an icons folder inside your newpackage directory and drop a file named newpackage.png there. 10)Populate databaseBy providing sample data you can populate the database during module install time. See Installer Data Pump for more information.11)Further reading
|