Page 1 of 1

remember path to current record

PostPosted: Sun Nov 18, 2007 11:25 am
by kurisusan
Hi,
is there a way to remember the 'path' to the current record through the tables' relationships? Imagine a geographic database which is structured into countries, cities, wards, streets, etc. When looking at the record of a street, I would like to be able to navigate back to the higher levels.
Regards, Christian

PostPosted: Tue Nov 20, 2007 1:27 pm
by shannah
Hi Christian,

You can implement a getBreadCrumbs() method in the delegate class which returns the *path* to the current record. It must return an associative array representing the breadcrumbs.

e.g.

Code: Select all
function getBreadCrumbs(&$record){
    return array(
        'Home' => DATAFACE_SITE_HREF,
        $record->val('countryName') => $record->val('countryRecord')->getURL(),
        $record->val('provinceName') => $record->val('provinceRecord')->getURL(),
        $record->val('cityName') => $record->val('cityRecord')->getURL(),
        $record->getTitle() => $record->getURL()
    );
}


Notes about this snippet.

1. I am using object chaining (PHP5 only)
2. The keys of the array represent the labels for the breadcrumbs.
3. The values of the array represent the link urls for those labels.
4. I am making reference to calculated fields that you would need to define (e.g. cityName, provinceName, countryName), but this is just an example of what can be done.

Hope this makes sense.[/list]

PostPosted: Wed Nov 21, 2007 2:48 am
by kurisusan
Thanks Steve, sounds good!

Once more I need to say that dataface is awesome. It is one of those software packages where whenever one of those 'it would be nice to have ...' thoughts comes into your mind, there is already a solution.

Regards, Christian