Page 1 of 1

navigation among related tables

PostPosted: Thu Dec 06, 2007 3:07 pm
by ststoddard
I am trying to make my app more user friendly and easier to navigate about in using urls.

Here is the situation. I have nested, related tables. I want a user to be able to enter any one of the tables and then easily go to related records in the other tables. e.g.

table1 -> tableB -> tablex
-> tabley
-> tablez

If a user looks at entries in tablex, I want to be able to go to the parent record in tableB -- or the grandparent in table1.

If I startout by entering table1 and descending down through related records, then I can make my way back by using:
$query =& $app->getQuery();
$x = $query['my_id_var'];

However, if one just goes straight into a child table, then I can't sort out how to get my hands on the variable values in a record to jump to another related table.

E.g. I want to put something in block__after_record_footer() that will reference values in the currently viewed record, permitting easy navigation to wherever. Yet the only thing I can get is the cursor value (i.e. $query['-cursor']). Using $query['my_id_var'] returns empty. And if I try:
function block__after_record_footer(&$record) {
...
$x = $record->val('my_id_val');

}

I just get an error.

???

Thanks.

PostPosted: Fri Dec 07, 2007 6:11 am
by kurisusan
I understood, that you have a tree like structure und want to be able to navigate back to the root of the tree?
In that case I'd suggest to make use of the 'bread crumbs' which are shown just below the table tabs.
You can provide your own bread crumbs using the getBreadCrumbs delegate method. In your case it might be sufficient however, to proivide the getParent delegate method. Therein you can query the database to find the parent of the current record and return that. Then the bread crumbs will show all the nodes on the way the current record can be reached from the root.
I'm currently to inplement exactly that but I'm having problems right now which will be the subject of a new thread...

Christian

PostPosted: Fri Dec 07, 2007 7:14 am
by Jean
Try use
Code: Select all
$_REQUEST
rather than
Code: Select all
$query

PostPosted: Fri Dec 07, 2007 7:15 am
by Jean
I mean for $query['-cursor']

PostPosted: Fri Dec 07, 2007 7:45 am
by shannah
There is a breadcrumbs example here
http://xataface.com/forum/viewtopic.php?t=4102#20624

Also in regards to your request var that is getting lost. As Jean mentioned above you could use the $_REQUEST array instead of the $query array. However the $query array should still be working.

One thing that is a bit of a convention in Dataface is to pass request vars with '-' preceeding the name. This indicates to dataface that the parameter should not be treated as a search parameter, but rather as extra instructions

e.g. index.php?-myparam=myvalue
This parameter will also be retained across requests when you click on links in the interface.

If you want to pass a parameter to your script but don't want it to be retained across subsequent requests you would use '--' to preced the parameter name:
e.g. index.php?--myparam=myvalue

Hope this helps a little.

PostPosted: Fri Dec 07, 2007 3:46 pm
by ststoddard
The breadcrumbs bit did the trick. Cheers.