Skip to main content

Download from GitHub and upload of plugin (2 Datasource Table)

  1. Navigate to HSYCO Manager

  2. Click on "File Manager"

  1. Navigate to "plugins" or create this folder if inexistent by clicking "New folder" in the left upper-side of the file manager.

Tip: Now we will download from the GitHub Repository the folder that contains the code and the project.

  1. Navigate to https://github.com/hsyco/hsyco4-examples

  2. Click "Code"

  1. Click "Download ZIP"

  1. Extract the hsyco4-examples.zip and navigate into "/table" to find the folder named "todolistdatasource2tables". Make that folder a .zip file.

  2. Click "Upload Files"

  1. Click "Select file" and select from your computer the todolistdatasource2tables.zip file that we just created.

  1. Click "Upload"

  1. As you can see, we have just imported the plugin successfully into our /plugin folder in HSYCO.

Tip: Now we have our plugin "todolistdatasource2tables" that contains the "events" folder and the "www" folder. Inside this folder there is the "projects" folder, and inside this a folder with the actual name of the project with a .xml file inside that specifies all the pages and object in this project. This method of having the project folder inside the main plugin folder is good if your plugin has associated interfaces. In our case, the project has a table object in a page associated to the code, so it is a good idea to make it as a plugin instead of just having the project folder in the root directory. If you want to make your own plugin, follow this guide on the wiki page: https://wiki.hsyco.com/3.8/index.php/Plugins_Applications You can create the project in the project editor like you would do normally and then move that folder under "/plugins/'ProjectName'/www/projects/"

Tip: Now I'll go in detail about the code

12. The first instruction, in the INIT, is used to retrieve the connection to the database. We store it in the "dbConn" variable and, after that, we set te AutoCommit to true. In this case, when a change in the database is made, it is autocommitted. Then, we execute a statement to the database that is used to don't identify null values as unique. This is used to avoid that, if two values are both null, they are treated as a single null.

  1. Now we execute the "Create" statement that creates the "todolist1" table with an autogenerated id, a date, a time and a 256 char text, and the "todolist2" table with an autogenerated id, a nested_id linked to the id of the first table and a 256 char text. If this operation is successful, a message is shown in the log.

14. Lastly, we set the SQLDataSource for the Project Editor linking "db_todolist1" to the table named "todolist1" which has "id" as a primary key, and "db_todolist2" to "todolist2". Then, in "db_todolist1", with a select query, we get all the values from the second table where their ids are the same. This gives us the possibility to modify the "buttonlabel" to show this number.

15. In the userCommand function, if the name is "showtodolist2", which is the command send by the button in the first table that we just saw, link all the values with the same id and redirect to the page where there is the second table. Otherwise, if the name of the command is "cleardb", which we will se later is a button used to clear all records in the database, execute the statement that does all of this. Then, with the "touch" option, we can "alert" the two databases that a change in one of them has been made. It may seem strange, but it is used to have a real-time change in the table, so that when we press that button, the records are deleted and the two tables empties in real-time because the database sees the change.