Page 1 of 1

PostPosted: Fri Aug 11, 2006 8:06 am
by maddin
hello everybody
even though i am working since a couple of years as a web develloper i am not really familliar with sql.
to me it would be very helpful to have a beginners tutorial on how to display data from 2 different tables (related) in one list view. since my english is not very good , a steb by step guide would be appreciated.

i extended the FacultyOfWidgetry example with a status field in the program table.
but how to make this status show up in the course list view?
i read all 118 forum topics to find a solution , but maybe i am to stupid...or i have to improve my english.

if somebody knows how and also could explain it in easy words ...

thanks and cheers
martin

PostPosted: Fri Aug 11, 2006 10:18 am
by shannah
Hi Martin,

Currently there is no easy way to display data from 2 tables in the list view. You can do this with a relationship in one of the relationship tabs though. If you need a more complex list view you can create a custom action and write your own SQL query and use a custom template. It is also possible to override the contents of the list tab in the delegate class as follows:

Code: Select all
class tables_Courses {

    function block__result_list(){
        echo '';
        $res = mysql_query('select c.*, p.status from Courses c left join Programs p on c.ProgramID=p.ProgramID');
        while ( $row = mysql_fetch_assoc($res) ){
            echo '';
        }
        echo '
'.$row['Name'].''.$row['status'].'
';
    }

}



This would cause the list tab to display a table with the course name and status (obtained from the programs table). Perhaps in the future I'll create some ini file directives to automate this process, but for now, this is the best way.

Hope this helps a little.

Steve

PostPosted: Sat Aug 12, 2006 3:26 am
by maddin
thanks Steve
your example for the delegate class works perfectly
unfortunately it also overrides the styles and the built in table logic (links etc.)
is it possible to extent the class instead of overriding it
if there is no easy way to do this , don't worry then i try to include my own styles
cheers and thanks
martin

PostPosted: Sat Aug 12, 2006 10:52 am
by shannah
Currently I can't think of a way to extend it. I'll look at adding this functionality in a later version. I don't believe it would be difficult.

Best regards

Steve