ITask2 Developer Guide Part2 Tutorial

download ITask2 Developer Guide Part2 Tutorial

of 56

Transcript of ITask2 Developer Guide Part2 Tutorial

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    1/56

    iTask 2.0 Content Management Backend

    DEVELOPER'S GUIDE Part 2 Tutorial

    codeArts Nepal Pvt. Ltd. 2008

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    2/56

    Table of contents

    No. Particulars Page No.

    1.

    Using the iTask1.1.Getting Started1.2.Table Convention: prefix, name and primary key(id)

    convention to use it with iTask1.3.Module Generation and access specifier:1.4.Structure of files created by module generator and their

    use1.5.Handling menu and module display in default module1.6.Adding, listing, editing, deleting data1.7.Using sub modules for ease of work and display sub

    modules in main module1.8.Module with image upload and display.1.9.Recommended Code read

    3 533 44 5

    5 1313 15

    15 2122 - 4444 48

    48 - 5353

    2. WaiTr Testing3. Conclusion 544. References 55

    1

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    3/56

    Abbreviations

    No. Abbreviation Full Form

    1. CMS Content Management System2. CRUD Create Read Update Delete

    2

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    4/56

    1. Using the iTask CMS1.1.Getting started:

    Unzip the iTast2.0.zip file in youre a folder to get the following folders, given inthe picture:

    1.1.1. Copy the module_generator and project_folder also to your htdocs folder1.1.2. Create a database from phpmyadmin named itask_db and dump the sql filein the db folder inside admin folder to the database via php myadmin.

    1.1.3. You can login to the system with username is admin and password is alsoadmin by going to http://localhost/project_folder/admin in your browser.

    1.1.4. You can rename the project_folder to your project name but do considerthe paths in tbl_cms_menu for desired functioning of the menu links.

    1.1.5. The configuration of the CMS is in the configuration.php file in the adminfolder. Its code is given below:

    3

    http://localhost/project_folder/adminhttp://localhost/project_folder/admin
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    5/56

    1.1.6. You can change the database details and path as per your need but

    remember to dump the database before trying to access the CMS.1.1.7. You will know other thing to change as you progress further in this

    document.

    1.2.Table Naming Convention:When naming your tables of your application/project it is advised to use a prefixto ensure smooth operation even in a multi-application and same databaseenvironment.For using table names in iTask CMS usually tbl prefix is used so the table letssay page will be tbl_page. For integration with iTask CMS it is mandatory to usethe primary id as table_name_id like for table page page_id will be the primarykey.In case the content should be published to be visible from the front end add afield "published" of type int(10) to handle this. For front end components andcomponents that need to be determined when it was created and edited appendtwo fields "register_date" and "modified_date" to the table both fields should beof datetime type. Refer to 3.3 for more details about why you should add this tothe tables. A typical tbl_page structure is given below:

    4

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    6/56

    *PS: Example of page module will be used for things below.

    1.3.Module Generation and access specifier:To generate your module copy the module_generator folder from the zip packageto your htdocs folder. Then follow the following steps to generate a module, herewe will generate a page module with above table structure.

    1.3.1. In your browser go to http://localhost/module_generator to get thefollowing page:

    5

    http://localhost/module_generatorhttp://localhost/module_generator
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    7/56

    1.3.2. Then in the form fill the details as below, explanation is given about thedetails filled. Use zoom to see the picture better. (Tip: use two browsers onewith phpMyadmin with table view and other with form below.)

    6

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    8/56

    1.3.3. After all the details are filled click generate module and then the followingpage appears:

    1.3.4. Check htdocs\module_generator\module_generator_iTask\generate_codefolder to get your mod_page folder as you named to module page in theabove form.

    1.3.5. Copy/move the mod_page folder fromhtdocs\module_generator\module_generator_iTask\generate_code to\htdocs\project_folder \admin\modules as shown below.

    7

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    9/56

    (Remember: project_folder is an imaginary name it will be the folder of theproject you are working on.)

    1.3.6. If this is your first module there will be 5 folder, 4 core required folder andnow added mod_page as below:

    8

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    10/56

    1.3.7. Then go tohttp://localhost/module_generator/module_access_generator_iTask/togenerate the access for the module/modules created.

    1.3.8. Click on Step1.php as below:

    1.3.9. Then type in your project folder name (project_folder is being used todemonstrate only).

    9

    http://localhost/module_generator/module_access_generator_iTask/http://localhost/module_generator/module_access_generator_iTask/
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    11/56

    1.3.10.After you click next following page appears:

    1.3.11.All the modules in the back end will be listed and their use will be givenas "Use by System" and "Published" to use it. Make sure all modules are"Published" and auth and default modules are checked for "Use by System".Then click generate SQL to get following page:

    1.3.12.Then copy all the code in the text area and go to your database like below:

    10

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    12/56

    1.3.13.Then paste it and click go.

    1.3.14.You will be informed of the query execution success as below.

    11

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    13/56

    1.3.15.Then login into your iTask admin at http://localhost/project_folder/admin/

    like below:

    1.3.16.Then click on "User Manager", to get a page similar to below:

    1.3.17.Notice that the URL ishttp://localhost/project_folder/admin/index.php?mod=user , edit the URL tohttp://localhost/project_folder/admin/index.php?mod=page to test if yourmodule works, if it does you will get the following page:

    12

    http://localhost/project_folder/admin/http://localhost/project_folder/admin/index.php?mod=userhttp://localhost/project_folder/admin/index.php?mod=pagehttp://localhost/project_folder/admin/index.php?mod=pagehttp://localhost/project_folder/admin/index.php?mod=userhttp://localhost/project_folder/admin/
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    14/56

    1.3.18.Ok you are done with adding module now other things will follow.1.4.Structure of files created by module generator and their use:

    On successful completion of the module generation your module folder youcopied/moved form "generate_code" folder to your respective modules folder hasfollowing files:

    1.4.1. Description of the 12 files created: (module_name is your module's namehere it is page as we are taking page module as the example module) all are.php files.

    1.4.1.1. class.module_name: is the main controller of all the things likelisting, deleting, editing that executes the processes. Other functions toadd related records should be coded here.

    13

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    15/56

    1.4.1.2. module_name: lists the database objects which has two databaseobjects database and database2, these are usable when you do codingfor related tables like if there is a menu for each page then link shouldbe maintained. Other things included in this file are the possibleoperation that can be run by default it has 5 operations add, edit, delete,

    enable and disable. Add, edit and delete operation from here andcreated needed files. Like if you want to add a new operation detail itcan be done from here and a file module_name.operation_name in ourcase page_detail.html.php should be created. It is the back end side ofthe page works in conjunction with module_name.html file.

    1.4.1.3.module_name.add: Performs the insertion process of the datasubmitted from module_name.add.html.php which contains the form toadd data. Message about record being added can be edited form here. Incase of related tables and adding multiple records like menu link recordfor the page should be added from here.

    1.4.1.4.module_name.add.html: The file has form and html elements to

    input the data. It has text field validation of Spry other validationshould be added by self if needed like checkbox validation. Refer toSpry section here for more details visit the URLs under Spry. In caseyou have to add select boxes and other elements in place of text fields itshould be coded by yourself in this file.

    1.4.1.5.module_name.delete: has code that calls the delete function in themodule_name.class file which deletes one or multiple records. In caseyou need to delete related records or multiple records then it should becalled here and coded in the module_name.class file.

    1.4.1.6.module_name.disable: has the code to disable one or multiplerecords, it changes the published to 0 calling the update function of themodule_name.class file.

    1.4.1.7.module_name.edit: Similar to module_name.add it gets the data fromthe module_name.edit.html which has the form and formats it to beupdated in the database. It calls the update function in themodule_name.class file.

    1.4.1.8.module_name.edit.html: has the form to edit the record it has thevalues stored in the database. In case of using select it should be codedspecifically for the value to be selected. It has form so needs sometweaking for validating other form elements except text filed.

    1.4.1.9.module_name.enable: has the code to enable the record/records bysetting the value of published field to 1 calling the update function inthe module_name.class file. It works as reverse of themodule_name.disable file.

    1.4.1.10.module_name.html : has the database objects by default databaseand database2 with actions/operations to be performed. Working inconjunction with module_name file (3.4.1.2) it also has four operationsby default add, edit, delete and list. If new database object is added saydatabase3 then it should be added in this file and module_name filesame for added operation like detail.

    14

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    16/56

    1.4.1.11.module_name.list.html: controls the listing of the fields of thedatabase table. The column types can be label for simple text, bool forBoolean value like published or unpublished. Link for link to edit it orview detail and image to display image.

    1.4.1.12.module_name.toolbar.html: has code to show the buttons in thetoolbar, in list mode there are 6 buttons as below:

    In case of Add and Edit operation 3 buttons are displayed as below:

    The buttons to be displayed as per operation can be controlled from thisfile.

    1.5.Handling menu and module display in default moduleShowing your module as a link in the menu may be vital for the user to use iteffectively. So it should be listed in the menu for ease of use. Continuing with thepage module example, let's assume there should be a Menu item called "FrontEnd" and have a link "Page Management" in it. For it let's analyze the tablestructure and the initial instance of the table tbl_cms_menu.

    Above is the schema of the table tbl_cms_menu.

    15

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    17/56

    Initially there are 15 records to show the menu as below:

    1.5.1. Showing your custom menu link and sub link in it: Now we will insertsome records in the database to show "Front End" menu link first then show"Page management" under it. Steps to do this are given below:

    1.5.1.1.Go to your phpmyadmin and to your tbl_cms_menu table then clickinsert as indicated below:

    16

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    18/56

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    19/56

    In my case it has id 4,note it down as well.1.5.1.8.Now insert a new record to the table tbl_cms menu as below:

    Similar to above addition but notice to parent is 814 of the "Front End"link.

    1.5.1.9.After the insert check the menu to get something like below:

    1.5.2. Displaying the module in the main default module list display, to do thisgo to /htdocs/project_folder/admin/modules/mod_default and spot thedefault.list.html file and edit it.

    18

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    20/56

    I'm using notepad++. Use your favorite IDE.1.5.3. You will see some code like below:

    19

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    21/56

    1.5.4. Paste the code below after the div close of mod=default&act=config

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    22/56

    1.5.7. If your module is for configuration or for other purpose and you feel the

    icon does not represent what the module does then you can change the icon.The options are:

    1.5.8. The icons are at htdocs/project_folder/admin/theme/images/header. See anexample where I changed icon-48-article.png to icon-48-frontpage to the"Page Management System" icon display.

    Resulted to:

    1.5.9. For further demonstration I'll change the icon back to icon-48-article.png.

    21

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    23/56

    1.6.Adding, listing, editing, deleting data:Now you have generated your module, added its link to the menu and even addedit to the main page display. Now let's add some data and see how things are done.

    1.6.1.

    Modifying toolbarYou might need to edit the toolbar to adjust things like the module namedisplay and the buttons displayed in the tool bar as per the operation. Referhere to see what this file shows.

    1.6.1.1. Change module name display in listing page.1.6.1.1.1. If you have noticed your "page manager" has a small p like

    below:

    1.6.1.1.2.

    Now lets change it to "Page Manager" so go to your modulesfolder an your mod_page folder to find page.toolbar.html.php fileand open it. to get code as below:

    1.6.1.1.3. Change it to something like below:

    1.6.1.1.4. Save the file, which will result to:

    1.6.1.1.5. You can name the module wish but maintaining consistencywith module_name Manager is preferred and advised.

    1.6.1.2.Changing buttons to display as per the operation:1.6.1.2.1. Typical button display as per the code below:

    22

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    24/56

    1.6.1.2.2. As per the above code add and edit operations have 3 buttons"Save", "Cancel" and "Help" you can remove help if its notneeded by delete that line's code.

    1.6.1.2.3. Let's remove "Publish" and "Unpublish" from the toolbar of thepage module just to check. To do this remove the two lines of

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    25/56

    1.6.2.1.2. In case of error you will get an error like below:

    1.6.2.1.3. So thing to consider here, in the form page your can see theright side is blank, you can add form elements there as well, wewill deal about it in next segment.

    1.6.2.1.4. Click "Save" button and you will get following notification ifyou have not error in data validation and get redirected to thelisting page as below.

    1.6.2.1.5. The data was successfully added, check database table viaPHPmyAdmin to confirm.

    1.6.2.2.Edit form appearance and behaviorIn the form page you might have noticed that the right part is blank andthere are only text field, text area and check box no select or radiobuttons. So let's make the URL a select box and just add a form on theright side of the menu item for the page a dummy on functional form.

    24

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    26/56

    1.6.2.2.1. To make the URL field a select box which is a text field nowgo to the page.add.html.php file in your mod_page directory. Itwill have code like below:

    1.6.2.2.2. Edit the

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    27/56

    1.6.2.2.3. Remember to comment the javascript to validate the URL ascompulsory. Done below:

    1.6.2.2.4. Save file and try to add a new page, you will get a form likebelow:

    1.6.2.2.5. Notice the Page URL field is a select box, also consider thatthe right part col40 div area is blank.

    1.6.2.2.6. Just fill in some data and click save, let it be the about us pagein the url. After adding page you will get a page something likebelow:

    26

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    28/56

    1.6.2.2.7. Now lets add a dummy form with menu related items to theright area of the form. To do this go to the page.add.html.php filein your mod_page directory. Add the code below just above.

    Menu Title:

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    29/56

    1.6.2.2.9. Notice the other table in the right side but it will not addanything as nothing has been coded for it in the class file and the

    page.add.php file.1.6.2.2.10.Lets see how the data gets added, the data form the for is

    thrown to page.add.php file which can be divided into two partspart 1 prepares data like below:

    1.6.2.2.11.Part 2 send the data in an array to class.page.php file to add todatabase table/tables:

    28

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    30/56

    1.6.2.2.12.The $database->insert($arr) function call, calls the insertfunction in class.page.php as given below:

    29

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    31/56

    1.6.2.2.13.So this is what happens. If you had to add a page with a menulink with a table called tbl_menu which had menu_id, page_id,menu_title and menu_url.

    1.6.2.2.14.Then in page.add.html.php you must first code the form asabove then in the page.add.php get the data of the menu title and

    menu body like below:

    30

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    32/56

    1.6.2.2.15.Changes in the class.page.php file should also be made, youshould code the InsertMenu function with related table asvariable, see below:

    1.6.2.2.16.You are done adding the menu but there is no table calledtbl_menu. You have to code these things in update and delete as

    31

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    33/56

    well to synchronize the functions. If a tbl_menu is created withabove mentioned fields the code should work.

    1.6.2.2.17.Single table addition are no big deal but related table additionshould be done like this, it's up to you to try it now. Test things.

    (Tip: multiple inserts can be handled by multiple functions as per need;

    always check the phpMyAdmin to test if your code is doing what it ismeant to do.)

    1.6.3. Listing/Displaying data:For the displaying as you have already seen that the data display from one table isautomated so we will try to see how to join tables and get data from joining table.For further examples we will use the same page module but we will display whichpage has what menu url in the display and things.

    1.6.3.1.Adding and listing related data1.6.3.1.1. So from the above diagram it is assumed that every page has a

    menu link. Now we will edit the add form to display somethinglike below:

    32

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    34/56

    1.6.3.1.2. The code to get this from in page.add.html.php and

    page.add.php is in the iTask_Sample_Modules folder inside

    mod_page folder or try it yourself to get something like this.1.6.3.1.3. Let's add a download page and see its listing in the listing pagewith page title, page url, menu title and published.

    1.6.3.1.4. After the page is added something like this is displayed:

    1.6.3.1.5. Now go to the class.page.php and find the code snippet thatdisplays the list above, function name is listAll.

    1.6.3.1.6. Edit the code to:function listAll() {

    $query = " SELECT$this->pms.page_id,$this->pms.title,$this->pms.url,$this->pms.published,$this->pms.register_date,$this->pms.modified_date,$this->tblmenu.menu_title

    FROM$this->pms,$this->tblmenu

    WHERE$this->pms.page_id=$this-

    >tblmenu.page_id";$this->Query ($query);

    }

    33

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    35/56

    Check the code in the iTask_Sample_Modules folder.1.6.3.1.7. Add the menu items for already created page so that they also

    display as the code has been edited to show two joined tables.Therefore, after you add the menu links for home and about uspage and add other pages you should get a list like below:

    1.6.3.1.8. Use your coder brain it's not as easy as it looks read the code inthe sample module folder.

    1.6.3.1.9. Order of column to be displayed depends on how it is selectedin listAll( ) function and how it is placed in the page.list.html.phpfile. Try to achieve the display below yourself, there is menu titleafter pageURL.

    1.6.3.2.Linking data display to edit or detail view.Lets say you want to add a link to the page title which loads the pageedit page you rather that checking the page and clicking the edit button.You can do it following the steps below:

    1.6.3.2.1. Open page.list.html.php file and find the following line:"url" =>array("header"=>"PageURL", "type"=>"label", "align"=>"center","wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),1.6.3.2.2. Edit it to:

    "url" =>array("header"=>"PageURL", "type"=>"link","align"=>"center", "wrap"=>"nowrap", "text_length"=>"-1","case"=>"normal", "field_key" => "page_id", "field_data"=>"url","href" => "index.php?mod=$module&act=edit&id={0}"),

    1.6.3.2.3. In above line the bold text is the added text.1.6.3.2.4. Now refresh your listing page it should be something like

    below:

    34

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    36/56

    1.6.3.2.5. Click in one of the pageURL links to get a form like below:

    1.6.3.2.6.

    If you change and edit the text it will be updated but as there isnot menu editing fields menu options will remain as it is.

    1.6.4. Editing dataEditing the data/records of a single table can be easily done with no codetweaking but in case of related data some coding is required. Lets get started:

    1.6.4.1. Edit the form page and enable related data editingTo do this, follow the steps below:

    1.6.4.1.1. Let's first edit the form and make it look like the form weedited to add the page and menu together.

    1.6.4.1.2. Copy the col40 div and its contents and frompage.add.html.php and paste it to page.edit.html.php just abovethe following line: (use the sample mod_page if its easy for you)

    1.6.4.1.3. The code will be something like below:

    35

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    37/56

    1.6.4.1.4. Now edit a record from the list, check it and click edit or justclick the pageUrl link to get the following form:

    36

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    38/56

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    39/56

    $meta_keyword = $database2->Fields('meta_keyword');$meta_description = $database2->Fields('meta_description');$body = $database2->Fields('body');$published = $database2->Fields('published');

    }unset ($_SESSION['page']);?>

    1.6.4.1.6. So the problem is Session does not have the values of themenu, notice that $database2->getDetail($page_id); is called sothis function should be altered in class.page.php file to get thevalues of the tbl_menu as well.

    1.6.4.1.7. Got the class.page.php file and locate getDetail function likebelow:

    1.6.4.1.8. Edit the Select sql to:$this->Query ("SELECT

    $this->pms.page_id,$this->pms.title,$this->pms.url,$this->pms.meta_keyword,$this->pms.meta_description,$this->pms.body,

    $this->pms.published,$this->tblmenu.menu_title,$this->tblmenu.menu_url,$this->tblmenu.menu_order,$this->tblmenu.published as published_menu

    FROM$this->pms,$this->tblmenu

    WHERE$this->pms.page_id = '$page_id' AND$this->pms.page_id=$this->tblmenu.page_id");

    1.6.4.1.9. Now goto the page.edit.html.php page and add the new menutable related variables to the code. First add session relatedvariables as below:

    38

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    40/56

    1.6.4.1.10.Then add variables to get form the database:

    1.6.4.1.11.Now check if the fields have the value variable of the col40 divmenu elements in case of select use the following code:

    1.6.4.1.12.If everything is ok you will get form like below on refresh.

    39

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    41/56

    1.6.4.1.13.Now you have successfully got the related values to the form,

    front end part is done with. For the back end interaction with thedatabase we will have to edit the page.edit.php file that gets thevalues on submission as in page.add.php.

    1.6.4.1.14.Got o page.edit.php and add the following code as below:

    1.6.4.1.15.Now prepare the array for updating as below:

    40

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    42/56

    1.6.4.1.16.After that call the functions to update the page and menu withsame sub query variable subQ as both have the same page_id, likebelow:

    1.6.4.1.17. The function update() is already present in class.page.php butupdateMenu() function, both functions take two arguments first isthe array to update and second is the sub query. updateMenu hasto be coded as below:

    1.6.4.1.18.Now save the files, refresh your edit form page and test yourupdate it must be functional. Mine is working see below,downloads is changed to downloads2 in both page title and menutitle: (See the code in mod_page in iTask_Sample_Modules folderif you have problem)

    41

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    43/56

    1.6.5. Deleting dataDeleting record/records of single table is easy as its already coded by thegenerator. In case of deleting record/records from multiple tablesfollowing steps should be followed:

    1.6.5.1.Deleting records from multiple tables1.6.5.1.1. Continuing with above example, if page is deleted its relatedmenu item must also be deleted so when a page it deleted weshould code a function to delete the related menu item fromtbl_menu.

    1.6.5.1.2. For doing this open the page.delete.php page in your mod_pagefolder, you will see code like below:

    1.6.5.1.3. So as there is possibility of multiple delete above code hasbeen generated.

    1.6.5.1.4. Add a function $database->deleteMenu($page_id) like belowto delete the menu record from tbl_menu related to the page to bedelete.

    1.6.5.1.5. Now save the file and code the DeleteMenu( ) function inclass.page.php as below:

    42

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    44/56

    1.6.5.1.6. Now when you delete the page its associated menu item willalso be deleted, try it see phpMyAdmin to verify its functionalitylike below:

    1.6.5.1.7. Before new release delete tbl_menu had

    1.6.5.1.8. Delete Process success

    1.6.5.1.9. After Delete tbl_menu has

    Similarly the page called new release has also been deleted, see below:

    43

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    45/56

    1.6.5.1.10.Check your operation from phpMyAdmin to verify it properly.1.7.Using sub modules for ease of work and display sub modules in main

    moduleLet's picture a scenario first, we are trying to get a main module that onlydisplays sub modules in side it all the work is done by the sub modules. So, inthis case lets take an example of "Page Elements" module as main module and"Block" module as its sub module.tbl_block has the schema as shown in 3.6.3, click here to go there and have alook at the schema. Follow the following steps to make your module and sub

    module structure clear:1.7.1. Sub modules holder main module and sub module addition

    1.7.1.1. Create a main modules directory in you modules folder like saymod_room that holds sub modules like chair and table.

    1.7.1.2. To make your main module that holds your sub module functionalcopy the mod_page_elements module's files only from theiTask_Sample_modules folder not sub folders to your directorysupposed room in your modules directory.

    1.7.1.3.After you copy, rename the files in your room folder as below:

    44

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    46/56

    1.7.1.4.Now open all the files and replace page_elemets by your new mainmodule's name here room is taken as example, so it will be like below:

    1.7.1.4.1. class.room.php code

    1.7.1.4.2. room.list.html.php code

    The above code displays

    45

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    47/56

    1.7.1.4.3. So if you browse tohttp://localhost/project_folder/admin/index.php?mod=page_elements{replace page_elements in the above URL with your module name} youshould get a page similar to above display.1.7.1.4.4. Now generate a module called block following the steps given

    at 3. 3 here and schema given in section 3.6.3 and lets make it asub module of your room main module.

    1.7.1.4.5. After you generate your module mod_block in generate codefolder rename the folder to block.

    1.7.1.4.6. Copy the folder to /htdocs/project_folder/admin/modules/your_main_module_name , yourmain module name is supposed room for this exercise.1.7.1.4.7. Then open the block.add.html.php and edit the code as followsOriginal line: Edit it to: - as room is supposed to be your main module'sname.

    1.7.1.4.8. Then open block.edit.html.php and edit a line of code asfollows:Original line: Edit it to: - room is supposed to be your main module.1.7.1.4.9. Now open the block.php file and edit the code to as below:

    46

    http://localhost/project_folder/admin/index.php?mod=page_elementshttp://localhost/project_folder/admin/index.php?mod=page_elements
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    48/56

    1.7.1.4.10.It is done to make add and edit function properly.1.7.1.4.11.Now you are done editing it, after that go to the main module

    room in this example and open room.list.html.php file

    1.7.1.4.12.Now access the module fromhttp://localhost/project_folder/admin/index.php?mod=room{Replace room with your module name}

    47

    http://localhost/project_folder/admin/index.php?mod=roomhttp://localhost/project_folder/admin/index.php?mod=room
  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    49/56

    1.7.1.4.13.Check the working of your block module it must be functional,if you have problems check the block module code in theiTask_Sample_modules folder.

    1.7.1.4.14.You can list your new main module in the menu and the defaultmodule list by following steps in 3.5.1 and 3.5.2.

    1.7.1.4.15.Try to get this and do edit the menu as well.

    1.8.Module with image upload and display.We have successfully added, updated and deleted data with use of module andeven sub module inside a module. Now let's add a module called Product whichwill even handle photos related to the product.

    48

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    50/56

    1.8.1. Handling image and file upload with module.1.8.1.1. For this example we will use a simple product table with just 4 fields

    as below:

    Product tables are not necessarily this simple but for the example we areusing a very simple product table to demonstrate the upload of image andthings.

    1.8.1.2. Lets populate our mod_product as below:

    1.8.1.3. Now copy the module form generate_code to you modules folder.1.8.1.4.Then generate the access to the module using access generator.1.8.1.5.After it add the menu link and or the icon on the main display page

    like below:

    49

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    51/56

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    52/56

    1.8.1.10. In case everything goes ok product will be added like below:

    1.8.1.11. Now to display the product picture correctly first verify that it hasbeen uploaded and the thumbnail has been generated correctly bybrowsing at /htdocs/project_folder/images/product as below:

    Verify thumbnail generation as well:

    1.8.1.12. Now open up the product.edit.html.php to edit the path to displaypicture on edit.

    1.8.1.13. Find the

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    53/56

    1.8.1.14. Then edit a product to get something like below:

    1.8.1.15. If you click save when editing there will be an error debug it bycommenting a line in product.edit.php as below as there is no modified

    date field in tbl_procuct:

    1.8.1.16. Something to notice:1.8.1.16.1.File name is based on the time and micro time the file is been

    uploaded so each time you replace a image new file name will be

    52

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    54/56

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    55/56

    2. ConclusionThis developer guide is a surface guide on using the iTask Content Management

    System (CMS), the possibilities are endless and as it has a modular design manythings can be efficiently incorporated in this highly flexible system. The extent of its

    can be known when you explore yourself, indulge in some code reading and try. Hitand trial may also bring out new avenues so start it now.

    This guide has be developed to give the kick start only now you are able to dosomething develop yourself to a better coder and a better solution provider usingiTask CMS 2.0.

    54

  • 8/14/2019 ITask2 Developer Guide Part2 Tutorial

    56/56

    Referenceshttp://en.wikipedia.org/wiki/Datagridhttp://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_deletehttp://en.wikipedia.org/wiki/Spry_frameworkhttp://en.wikipedia.org/wiki/TinyMCE

    Thttp://en.wikipedia.org/wiki/Content_management_system

    http://en.wikipedia.org/wiki/Datagridhttp://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_deletehttp://en.wikipedia.org/wiki/Spry_frameworkhttp://en.wikipedia.org/wiki/TinyMCEhttp://en.wikipedia.org/wiki/Content_management_systemhttp://en.wikipedia.org/wiki/Content_management_systemhttp://en.wikipedia.org/wiki/TinyMCEhttp://en.wikipedia.org/wiki/Spry_frameworkhttp://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_deletehttp://en.wikipedia.org/wiki/Datagrid