form output and ordering
19 posts
• Page 1 of 2 • 1, 2
ok, two questions here.... hopefully should be my last questions, but i want to implement something that would make a "printer friendly" version of the database, much like if you were to use "reports" in micro$oft access. and the second, i have about 10 columns in the database, and i want to organize the entire table alphabetically by the "description" column. i can do this by clicking "description" each time, but id like it to always be ordered that way.
You can add the sort to your URL so that you can link directly to a page that is already sorted properly. You use the "-sort=colname" parameter in the url.
e.g. http://yourdomain.com/yourapp/index.php?-table=foo&-action=list&-sort=description or something like that. Does that help. If that isn't good enough, you can hard-code this into your index.php file: if (!@$_GET['-sort'] and $_GET['-table'] == 'foo'){ $_GET['-sort'] = 'description'; $_REQUEST['-sort'] = 'description'; } If you're looking to make a special report page that is nice for printing, you may want to just make a custom action though and lay it out exactly the way that you want. Best regards Steve
thank you, that does indeed help. but how do i make a custom action to do this? basically i just want to strip it down, and have it in a basic table, so that each one will fit on an 8x11 sheet, landscape
Start with the tutorial: http://framework.weblite.ca/documentation/tutorial/getting_started/dataface_actions
This just shows the basics, but should get you started.. -Steve
You can add the sort to your URL so that you can link directly to a page that is already sorted properly. You use the "-sort=colname" parameter in the url. ok, i tried the one on the url, and had to remove the -table=foo from the end for it to operate properly, but how would i form the hard code like this so that it would work?
The -table=foo was an example. If your table was named bar it would be -table=bar. Basically, you can take any url from your app, and add -sort=description to have it sort by description. Or -sort=id to have it sort by id.
-sort=id+desc
Will sort the id field in descending order -sort=id+desc,name+asc Will sort lexicographically descending by id, and ascending by name. Hope this helps -Steve
I followed the tutorial's example and modified it to match what I'm trying to do (which is create a printer friendly page)...When I execute my print action I get the following warnings:
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1902 Warning: reset() [function.reset]: Passed variable is not an array or object in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1918 Warning: current() [function.current]: Passed variable is not an array or object in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1923 so far, my action code looks like: function handle(&$params){ $app =& Dataface_Application::getInstance(); // reference to Dataface_Application object $results =& $app->getResultSet(); // Current found set (Dataface_QueryTool object). // Iterating through the results $it =& $results->iterator(); while ($it->hasNext() ){ $record =& $it->next(); // $record is a Dataface_Record object print_r($record->strvals()); unset($record); // necessary so that PHP doesn't just keep overwriting the same object. } df_display(array(), 'Printer_Friendly.html'); } my basic idea is to add a button under the resultset from the original view, that button is a part of a form that uses my print action. The print action gets the current result set and prints it into a new template which I will format to look how I need it to. Maybe my logic is far off...... but for now, I don't know where these errors are coming from. Thanks in advance!
I followed the tutorial's example and modified it to match what I'm trying to do (which is create a printer friendly page)...When I execute my print action I get the following warnings:
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1902 Warning: reset() [function.reset]: Passed variable is not an array or object in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1918 Warning: current() [function.current]: Passed variable is not an array or object in /home/bmmcom/public_html/dataface/Dataface/Record.php on line 1923 so far, my action code looks like: function handle(&$params){ $app =& Dataface_Application::getInstance(); // reference to Dataface_Application object $results =& $app->getResultSet(); // Current found set (Dataface_QueryTool object). // Iterating through the results $it =& $results->iterator(); while ($it->hasNext() ){ $record =& $it->next(); // $record is a Dataface_Record object print_r($record->strvals()); unset($record); // necessary so that PHP doesn't just keep overwriting the same object. } df_display(array(), 'Printer_Friendly.html'); } my basic idea is to add a button under the resultset from the original view, that button is a part of a form that uses my print action. The print action gets the current result set and prints it into a new template which I will format to look how I need it to. Maybe my logic is far off...... but for now, I don't know where these errors are coming from. Thanks in advance!
I apologize for the mistake in the example.
Before calling iterator() you need to call loadSet() on the $results object. e.g. $results->loadSet(); $it =& $results->iterator(); ... An alternative to this method is to obtain the user query using $app->getQuery(), and pass that to df_get_records_array() to return an array of Dataface_Record objects that you can loop through. e.g. $query =& $app->getQuery(); $records =& df_get_records_array($query['-table'], $query); foreach ($records as $record){ // do something with the record }
I'm sorry about soo many questions about what should be simple things. Ive searched and searched through the documentation, cannot find any way to loop through the fields of a given record.
Lets take your last response a step further: $query =& $app->getQuery(); $records =& df_get_records_array($query['-table'], $query); foreach ($records as $record){ } now within the for loop, I'm trying to get another for loop to go through each field in the record to construct a table: echo '
I realize this is very sloppy but I just need something for now, then I can clean it up later =) So far, if I put in the[ print_r($record->strvals()); ] without a loop for the fields, I can get all the record data in a "toString()" type of format, and the table creates as desired. But each record is in one cell and has more information than I want (obviously). Thanks again for all your help, sorry again for being such a pain.
Let me see if this shows up better, looks like some of my code got processed in my last post =/
19 posts
• Page 1 of 2 • 1, 2
Who is onlineUsers browsing this forum: No registered users and 12 guests |