Skip to content
jelmersnoeck edited this page Nov 5, 2011 · 4 revisions

*Note, this will work with 2.x and 3.x versions of Fork. *Note that this also applies to ajax handlers and widgets.

Basic action

To create an action, we need some more variables. These are the module name and the location to create the action on. For the Fork tool we set the locationpath with frontend= or backend= (you can also use the short version, f= or b=).

Notation: ft action <modulename> <location>=<actionname>

For example: ft action blog f=detail,category b=add,edit

When this command is ran, there will be automatically generated a .php and a .tpl file in the right directories. The files will have some basic structure.

Advanced

The tool has some intelligence to know wich type of action it should create. For example, if you add an action edit_category it will create an edit block. You can also overrule this, all you have to do is add the type you want after your action. For example: ft action blog b=foo:edit will create an edit action. This works only on the backend. The actions that are available are index, add, edit, delete.

When you create a delete action, there will not be generated a template file.

Note that you can add multiple actions at once. It is also possible that you forgot one action in the frontend, but you don't want to type everything again. Then you just do ft action blog f=detail,category b=add,edit f=overview.

Names

The names that you use will automatically be camel-cased. This means that if you have an action add_category, this will be converted to AddCategory. Though, the files will be created as add_category.

Backend actions will also automatically added to the installer for later use.

Blocks

For some frontend actions you need an extra block. This is also easily possible by just adding ':block' to your action. For example ft action blog f=detail:block.

Blocks will automatically be added to the installer. Though, you need to keep the line // add extra's in your installer.

Ajax and Widgets

Since the main functionality is the same as actions, I've placed this on this page. For both actions, the folders will only be created if you create an ajax call or widget(both the php and template folder).

Ajax

When you need an ajax handler, you can simply create this by typing ft ajax <modulename> <location>=<ajaxhandler>.

As for actions, you can create multiple ajax handlers at once. The only difference here is that there will not be created any template file, wich is logical.

Widgets

When you create a widget, this will automatically be added to the database, so you can start assigning them immediately. The principle to create a widget is ft widget <modulename> <location>=<widgetname>.

Widgets will automatically be added to the installer. Though, you need to keep the line // add extra's in your installer.

Clone this wiki locally