( ! ) Warning: constant(): Couldn't find constant NEWPACKAGE_PKG_PATH in /var/www/bitweaver/live/themes/smartyplugins/function.biticon.php on line 214
Call Stack
#TimeMemoryFunctionLocation
10.0001231104{main}( ).../page_history.php:0
20.20023679656include_once( '/var/www/bitweaver/live/liberty/includes/content_history_inc.php' ).../page_history.php:42
30.20783692736LibertyContent::parseDataHash( ).../content_history_inc.php:32
40.20813700880parse_data_plugins( ).../LibertyContent.php:3051
50.21053750904data_biticon( ).../liberty_lib.php:111
60.21113752488smarty_function_biticon( ).../data.biticon.php:74
70.21153753968constant ( ).../function.biticon.php:214
- bitweaver

Version 18

Tutorial_Custom_Package

Created by: Simon Benedicic, Last modification: 07 Aug 2005 (08:36 UTC) by Simon Benedicic

Introduction

This 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

  • Go to the root of your bitweaver installation and make a directory:
{CODE()}$ mkdir newPackage
$ mkdir newPackage/modules
$ mkdir newPackage/templates{CODE}

2) Create your table

  • In your bitweaver database, create a table called test_table, and add two colums: test_table_id, and memo, or use the sql below
{CODE()}CREATE TABLE test_table
(
test_table_id int NOT NULL,
memo text[]
) WITHOUT OIDS;{CODE}

Insert several rows into the table.
{CODE()}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

  • Go to newPackage/ and create a file called index.php
  • Add the following lines
{CODE()}<?php
require_once('../bit_setup_inc.php'); //initialized the entire system!
$result = $gBitSystem->query("SELECT * FROM test_table");
$smarty->assign('test_table', $result->GetArray());

$gBitSystem->display( 'bitpackage:newPackage/newPackage.tpl', 'New Package Page' );
?>{CODE}

4) Create your package's bit_setup_inc file

  • Go to newPackage/ and create a file called bit_setup_inc.php
  • Add the following lines (the spaces in _ _FILE_ _ must be removed wiki thinks they should bold the FILE ! )
{CODE()}<?php
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

  • Now go to newPackage/templates and create a file using pico, or whatever you use, called newPackage.tpl
  • Add these lines:
{CODE()}
{$test_tablecolnum.test_table_id}{$test_tablecolnum.memo}
{CODE}

At this point you have to activate your new package in Admin Packages


Voila!

Go to http://yourbitweaverURL/newPackage/ and your table should be displayed!

6) Now, create a Module

  • Create a module (a little box that you can display in the left or right columns) with a pointer to your awesome new package.
{CODE()}$ mkdir newPackage/modules{CODE}
  • and create a file using pico, or whatever you use, called mod_newPackage.tpl.
  • The file name must be formated like this so bitweaver can include it in the Administration / Modules dropdown list.
  • Add these lines to the file:
{CODE()}
Planning
this is a cool iconMy New Package
{CODE}
(: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

7) List of available constants in bitweaver


automagically generated constants for each package of the form
<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

in addition there are a few more
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

8)Make the package installable

In order to make the package installable, you need an additional directory in package
/admin
{CODE()}$ mkdir newPackage/admin{CODE}
and the schema information to chack the database with which comes in the form of aschema_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>
Page History
Date/CommentUserIPVersion
14 Jan 2007 (13:14 UTC)
Add reference for testing
hiran85.233.40.19244
Current • Source
hiran85.233.40.19243
View • Compare • Difference • Source
hiran85.233.40.19242
View • Compare • Difference • Source
hiran85.233.40.19241
View • Compare • Difference • Source
hiran85.233.40.19239
View • Compare • Difference • Source
xing194.152.164.4538
View • Compare • Difference • Source
xing194.152.164.4537
View • Compare • Difference • Source
hiran85.233.40.19236
View • Compare • Difference • Source
hiran85.233.40.19234
View • Compare • Difference • Source
hiran85.233.40.19233
View • Compare • Difference • Source
hiran85.233.40.19232
View • Compare • Difference • Source
hiran85.233.40.19231
View • Compare • Difference • Source
hiran85.233.40.19230
View • Compare • Difference • Source
hiran85.233.40.19229
View • Compare • Difference • Source
hiran85.233.40.19228
View • Compare • Difference • Source
hiran85.233.40.19227
View • Compare • Difference • Source
hiran85.233.40.19226
View • Compare • Difference • Source
alexh84.112.104.14825
View • Compare • Difference • Source
johnnoone81.56.46.1524
View • Compare • Difference • Source
Sean Lee71.241.129.17423
View • Compare • Difference • Source
spiderr66.93.240.20422
View • Compare • Difference • Source
Sean Lee71.241.129.17421
View • Compare • Difference • Source
Jan Lindåker81.229.122.24919
View • Compare • Difference • Source
Simon Benedicic193.77.101.1418
View • Compare • Difference • Source
Lester Caine81.138.11.13617
View • Compare • Difference • Source
Lester Caine81.138.11.13616
View • Compare • Difference • Source