Hi Jerry,
Thanks for the compliments. I haven't written this part of the tutorial (there are about 7 more sections that need to be written to cover the new features in this version), but here's the gist.
In the tutorial I have only showed one half of the actions framework (using the actions.ini file and a template). For more complicated things, you will also need a custom action handler.
Continuing the hello world example:
Your actions.ini file has:
[hello]
template=HelloWorld.html
Add a folder to your application named "actions".
Inside this folder, add a file named "hello.php" with the following contents:
- Code: Select all
class actions_hello {
function handle($params){
$res = mysql_query("SELECT Foo FROM Bar where Foo.bar='1'");
$records = array();
while ( $row = mysql_fetch_assoc($records) ){
$records[] = $row;
}
$context['records'] =& $records;
df_display($context, 'HelloWorld.html');
}
}
?>
Then in your HelloWorld.html file it would become something like:
- Code: Select all
{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_section"}
{foreach from=$records item=record}
Name: {$record.name} - Description: {$record.description}
{/foreach}
{/fill_slot}
{/use_macro}
Note that you can also have your action show up along with other actions (e.g. the details, list, find tabs) by setting a category attribute.
e.g.
[hello]
category = "table_tabs" ; Causes it to show up in the details/find/list tabs
;category = "table_actions" ;; this would cause it to show in the actions menu (new record, show all, etc..)
;category = "result_list_actions" ;; Shows up in the top right of result lists (as an icon only).
url = "{$this->url('-action=>hello')}"
label = "Hello World"
description = "Does the Hello world action"
icon = "myicon.gif"
For a good idea of the available options, look at the dataface/actions.ini file. A brief description of the options are:
url : the url that should be called when the action is clicked (this can be any url - php statements inside curly braces - $this is a reference to the application object. $this->url('-action=hello') builds a url to the application but with -action =hello.
icon : The icon that is displayed next to the action (if applicable).
Hope this helps.. better tutorial coming soon
Best regards
Steve