Syntax of actions.ini to filter a tab by a field

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

Syntax of actions.ini to filter a tab by a field

Postby rleyba » Sat Jun 23, 2012 2:19 am

Hi Steve,

I just need some help with the syntax of a tab I need to add in my application. I already have an existing actions.ini file which shows other actions and views in my application. The app is a change management system and one of the fields I have is ImplementationStartday which is a Date-Time field. I want to create a shortcut wherein my users can click on a tab and it shows "changes for today" and another tab that shows "changes for tomorrow". Since my ImplementationStartday field is date-time format, I need to extract only the date portion. How might the construct be? What would be the structure of the URL portion? I was thinking in the lines of the one below but I cant get the exact syntax. Also how would I represent "tomorrow" -- i.e. (today()+1?:


Code: Select all
[changes_for_today]
    category=table_tabs
    url="{$site_href}?-table=ChangeRecord&-action=list&-mode=list&Date(ImplementationStartDay)=today()"
    condition="$query['-table'] == 'ChangeRecord'"
    permission=list
    order=3


Thanks very much.
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm

Re: Syntax of actions.ini to filter a tab by a field

Postby shannah » Sun Jun 24, 2012 10:50 am

You are close, but you can't call SQL functions like Date() as part of the GET parameters. The way to do this is to either provide absolute date ranges to the GET parameters
e.g.
&date=2012-09-01..2012-09-02

or add some columns to your table's SQL query via the __sql__ directive of the fields.ini file to make it easier for you to query things like today and yesterday

If you wanted to go the first route, you could define constants somewhere in your app and include them in the url directive (see http://ca2.php.net/manual/en/function.p ... i-file.php) for information about how to use constants in INI files.

If you wanted to go the second route you would create grafted fields that could be searched easily to find whether the date is today, yesterday, etc... Then your GET parameters would search on that grafted field instead of the date field itself. E.g. if you created a grafted field that contained the number of seconds since it was inserted you could easily perform queries for records that had been inserted within the past X hours or days. You might alternatively go the boolean route and just create grafted fields "yesterday" and "today" that would contain 1 if the record was inserted on that day, and 0 otherwise. Then you could also easily search for all records inserted yesterday - or all inserted today, etc....

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Syntax of actions.ini to filter a tab by a field

Postby rleyba » Sun Jun 24, 2012 11:33 pm

Hi Steve,

Thanks....it makes sense to me now. I think I will go the 2nd route.
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 5 guests

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