two 'actions' questions: 1. templating, 2. table tabs

A place for users and developers of the Xataface to discuss and receive support.

Postby shiraz » Thu Jan 18, 2007 5:43 pm

Hello there,

I'm loving the new Actions functionality in Dataface. I've run into two problems though:

1. The "Actions I" tutorial first teaches how to use a Smarty HTML template, then an Action Controller PHP class. It notes that the benefits of formatting via a Smarty templates are lost with the controller class, and suggests you can regain the formatting by calling the df_display function to the Smarty template.

The problem is, how do you *embed* the PHP results from the controller class in the template's display? I'm simply trying to get the results of the Controller class's output (it does some SQL queries and has some user forms) to be prionted within the standard Dataface template, ie. in the content section.


2. Are all the "table tab" categories in actions.ini working yet? It seems only the "Table Actions" are working currently. I tried adding some Relationship Actions (using "category = relationship_actions" in my own actions.ini file) and it didn't work. In fact, I edited the source actions.ini file (in the dataface directory) to a 0-byte file, and then browsed my database. The only tabs that went missing were the Table Actions. The rest continued to work, using the source code rather than the actions file.



Warmest regards,

Shiraz
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Jan 19, 2007 12:59 am

1. The first parameter of df_display is an array that is meant to be the context of the template. You can pass whatever variables you need into the template there.

e.g.

Code: Select all
$res = mysql_query("select firstname,lastname,phone from people");
$results = array();
foreach ($row = mysql_fetch_assoc($res) ) $results[] = $row;
df_display(array('my_results'=>&$results), 'My_Template.html');


Then in your My_Template.html file:
Code: Select all

{foreach from=$my_results item=record}
   
       
       
       
   
{/foreach}
{$record.firstname} {$record.lastname} {$record.phone}




2. Actions are used in a couple of ways. They can appear as tabs or buttons (as in the case of table_tabs or table_actions), but they don't necessarily have to appear that way. Entries in the actions.ini file can also just set up the permissions etc... for actions that can be callable via url only (e.g. -action=action_name).

Actions are accessible from your smarty templates as follows:

{actions var="my_actions" category="my_category"}
{foreach from=$my_actions item="action"}
{$action.label}
{/foreach}

This assumes that in your actions.ini file you have a few actions specified with category "my_category"
The good thing about doing it this way is that you can easily add actions later by simply adding them in your actions.ini file. You can also use the "condition" or "permission" attribute for an action to limit who can see it.

I really need to do a full tutorial on this... but that is the bare bones..

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Sun Jan 21, 2007 2:38 am

Hi Steve,

Thanks again for your very clear explanations. I was successful with #1. Just FYI, I buffered the output of my delegate class code and at the end I send this buffer to the template with:

df_display(array('shirazcontent'=>ob_get_clean()), "Dataface_Main_Template.html");

That way all the logic is handled within the delegate class rather than trying to use Smarty to do too much.



Your explanation for #2 also helped considerably.

One small question remains -- the actions.ini does show a relationship_actions category. But adding such an action has no effect. Am I to understand that this is simply because what I'm seeing is the start of this functionality that's not yet complete? For now, I have added my own relationship actions by hacking RelatedList.php but it's less elegant than the former approach.


Blessings,

Shiraz
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Jan 22, 2007 1:19 pm

Hi Shiraz,

I had to jog my memory a bit to remember what the deal was with the relationship actions. Yes.. it is incomplete functionality. The intention eventually is to make it so that when you check the boxes beside records in the related records list, you can do more than just delete them - these actions would be part of the relationship_actions category.

But .. haven't had a chance to finish it.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shiraz » Tue Jan 23, 2007 2:09 pm

Ahh, thanks, that clarifies things. I'd thought I may have been missing something obvious. Glad I wasn't! :D
shiraz
 
Posts: 55
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 30 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved