Kohana module
I have just build my first Kohana module. It is a mess right now, but it is only a try that become to something. It is possible that I must to rewrite it completely.
You can get the code to test it , but it can be changed quickly and it can be not behind compatible.
This module allows to generate dinamically views for our model and controller.
Steps to use it are next ones:
Make the “modules/defaultsite” folder and download there my module.
Edit the file bootstrap.php, keyword “kohana::modules”, and add the line: ‘defaultsite’ => MODPATH.‘defaultsite’
Now the fun begins: we are going to make our site.
- Create your database.
- Create your model. It is just like ever.
- Create your controller: just the same as ever with Kohana, but inheriting from Controller_Default. Writing the constructor is enough.
That’s all. You can access your site.
Example
BBDD
|
|
model/example2.php
|
|
controller/example2.php
|
|
Explaining
In this point, you can admin “type 2” elements.
In my host, I have to access /index.php/example2
to admin it. As you can see, pages are very simple, but completely functional.
Index is dinamically generated and it allows you to delete, update or create new items.
You can change columns, but I’m going to skip that because it is only a scaffold.
If you want to see the other table functionality, it is necessary to add some values.
model/example1.php
|
|
controller/example1.php
|
|
Explaining
If we add some “tipo Example1” items, we will see that the different types of buttons are sensitive to the selected type: texts are textarea, dates use jquery to show a calendar, BLOB show an input file filed (ouch, it is a scaffold yet) and foreign keys are shown like a combobox with all its items.
Final
Nowadays it is only a scaffold, because I have been 2 weeks with Kohana and my PHP knowledge is too poor. Help is needed!!