Hello World TutorialStep 1First of all let's create a new empty package. Here are the steps to do this:1. Go to the directory %install_dir%/packages/ and create a new directory _hello_world. It's a some kind of convention that names of all project's packages showld be started with the '_' character. 2. Open the file %install_dir%/packages/core/data/package_list and add the following line of code at the end of it: Code:
hello_world.1.0.0#_hello_world Step 2Now we will create the package itself.1. Create the directory %install_dir%/packages/hello_world 2. Create the file %install_dir%/packages/hello_world/hello_world.php Note that the name of the package and the file name of it's php script must be the same. 3. Open the file %install_dir%/packages/hello_world/hello_world.php and add the following code: Code:
class hello_world_1_0_0 { function view( $Options ) { return( 'hello world' ); } } In this code you can see that class name contains of the package's name and i's version. Step 3Here is the last step of this tutorial. Let's create a standalone page to output 'hello world'.1. Go to the directory %install_dir%/packages/page/packages/page_access/data and create in this directory two files: Code (hello_world):
Hello world!#default#default#predefined_packages=1 Here we tell to the system that we are creating page with title 'Hello world!', with the default template and all standart packages showld be attached to this page. Second file: Code (pa_hello_world):
hello_world#last#view=1#main Here we tell to the system that we want to display view from the package 'hello_world' and it mast be placed in the 'main' block of the template. 2. The page was created. Now let's make it visible for public users. Right now if you open the page http://yourdomain/hello_world.html you will see an error message that you don't have permits to do this. It can be easyly explained: all new pages may be accessed by user with the admin permit. It was done so because of the security reasons. To change access permits go to the directory %install_dir%/packages/permit/packages/permit_acess/data and create there a file 'phello_world' with the following content: Code (phello_world):
public Here we set 'public' permit to our page. In the default configuration all users have 'public' permit. So the page will be visible for all users. Now visit the page http://yourdomain/hello_world.html and behold ). |
2009 © ultimix |