History of Tutorial_Custom_Package
~~--FF0000:!Displaying your Own Table in TikiPro~~
!__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 TikiPro, 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 Package__
* Go to the root of your tikipro installation and make a directory:
** >mkdir newPackage
** >mkdir newPackage/modules
** >mkdir newPackage/templates
!__2) Create your table (where your data lives)__
* Using postgress, and a neet utility like [http://www.pgadmin.org/pgadmin3/index.php|pgAdmin3] create a database called test_table, and add two colums: nameid, and memo, or use the sql below
CREATE TABLE test_table
(
nameid int2 NOT NULL,
memo text[],
CONSTRAINT test_table_pkey PRIMARY KEY (nameid)
);
!__3) Create your php file (where the logic goes!)__
* go to newPackage/ and create a file called index.php
* add the following lines
** <?php
** require_once('../tiki_setup_inc.php'); //initialized the entire system!
** $result = $gTikiSystem->query("SELECT * FROM test_table");
** $smarty->assign('test_table', $result->GetArray()); //assigning the results into test_table creates a smarty variable that will be passed to your template!
$gTikiSystem->display( 'tikipackage:newPackage/newPackage.tpl' );
// this will will plop all data into the newPackage template you are going to make
next
?>
!__4) Create your tpl file (where the presentation goes!)__
* Now go to newPackage/templates and create a file using pico, or whatever you use, called newPackage.tpl
** add these lines:
*** <table border=2>
** {section name=colnum loop=$test_table}
** <tr>
** <td>{$test_table[colnum].nameid}</td>
** <td>{$test_table[colnum].memo}</td>
** {/section}
** </table>
Voila!
Go to http://yourTikiProURL/newPackage/
and your table should be displayed!
!__5) Now, create a module (a little box that you can display in the left or right columns) with a pointer to your awesome new package
* mkdir newPackage/modules and create a file using pico, or whatever you use, called mod_newPackage.tpl.
* The file name must be formated like this so the tikisystem can include it in the administration --> modules -> dropdown list.
* add these lines to the file:
<table cellpadding=4 border=2>
<tr>
<td class="boxtitle"><b>Planning</b><br></td>
</tr>
<tr>
<td><a href="{$gTikiLoc.newPackage_PKG_URL/index.php">
<img src="{$gTikiLoc.IMG_PKG_URL}icons/acoolicon.gif"
class="icon"
alt="{tr}my new package{/tr}"
title="{tr}my new package{/tr}" />
Weekly Plans</a></td>
</tr>
</table>
(:exclaim:)//$gTikiLoc.whatever_PKG_URL is a pointer to a folder called whatever in the root
//and is a very cool way of accessing icons... check out the IMG folder to fancy up
//your site!
I hope this helps!
!__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 TikiPro, 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 Package__
* Go to the root of your tikipro installation and make a directory:
** >mkdir newPackage
** >mkdir newPackage/modules
** >mkdir newPackage/templates
!__2) Create your table (where your data lives)__
* Using postgress, and a neet utility like [http://www.pgadmin.org/pgadmin3/index.php|pgAdmin3] create a database called test_table, and add two colums: nameid, and memo, or use the sql below
CREATE TABLE test_table
(
nameid int2 NOT NULL,
memo text[],
CONSTRAINT test_table_pkey PRIMARY KEY (nameid)
);
!__3) Create your php file (where the logic goes!)__
* go to newPackage/ and create a file called index.php
* add the following lines
** <?php
** require_once('../tiki_setup_inc.php'); //initialized the entire system!
** $result = $gTikiSystem->query("SELECT * FROM test_table");
** $smarty->assign('test_table', $result->GetArray()); //assigning the results into test_table creates a smarty variable that will be passed to your template!
$gTikiSystem->display( 'tikipackage:newPackage/newPackage.tpl' );
// this will will plop all data into the newPackage template you are going to make
next
?>
!__4) Create your tpl file (where the presentation goes!)__
* Now go to newPackage/templates and create a file using pico, or whatever you use, called newPackage.tpl
** add these lines:
*** <table border=2>
** {section name=colnum loop=$test_table}
** <tr>
** <td>{$test_table[colnum].nameid}</td>
** <td>{$test_table[colnum].memo}</td>
** {/section}
** </table>
Voila!
Go to http://yourTikiProURL/newPackage/
and your table should be displayed!
!__5) Now, create a module (a little box that you can display in the left or right columns) with a pointer to your awesome new package
* mkdir newPackage/modules and create a file using pico, or whatever you use, called mod_newPackage.tpl.
* The file name must be formated like this so the tikisystem can include it in the administration --> modules -> dropdown list.
* add these lines to the file:
<table cellpadding=4 border=2>
<tr>
<td class="boxtitle"><b>Planning</b><br></td>
</tr>
<tr>
<td><a href="{$gTikiLoc.newPackage_PKG_URL/index.php">
<img src="{$gTikiLoc.IMG_PKG_URL}icons/acoolicon.gif"
class="icon"
alt="{tr}my new package{/tr}"
title="{tr}my new package{/tr}" />
Weekly Plans</a></td>
</tr>
</table>
(:exclaim:)//$gTikiLoc.whatever_PKG_URL is a pointer to a folder called whatever in the root
//and is a very cool way of accessing icons... check out the IMG folder to fancy up
//your site!
I hope this helps!