Look of the database module

Look of the database module

by Josep M. Fontana -
Number of replies: 4
I was hesitating whether to post this query in the database module forum or here and eventually I chose this forum because more people who know about HTML and CSS hang out here than there.

OK, the problem is that the look you get with the default template for 'view list' is not the one I want. The one I want is the most logical one (the one we have in the databases at moodle.org:

http://docs.moodle.org/en/Database_module#Example_databases

I've tried to change the default table that comes in template for 'view list' but what I get is the following:
db

What can I do to get a single table header? As you see, if I add the table header in the template table, it shows for every record. If I eliminate it from there, it doesn't show anywhere. Also, the contents of the cells are not aligned either and I don't know how to get them aligned.

Any help you might offer will be greatly welcome.

Josep M.
Average of ratings: -
In reply to Josep M. Fontana

Re: Look of the database module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Note that template page has three text fields. The top one is shown at the top, the middle one is repeated for each record, and the last one is shown at the bottom.

So your table headers go in the top one.
In reply to Martin Dougiamas

Re: Look of the database module

by Josep M. Fontana -
I'm afraid I'm not understanding something. You say the "template page has three text fields". As I understand it, the template page will have as many fields as you add when you are configuring the specific database. So, for this particular database, once I designed it and added all the needed fields, I got the following default table when I clicked on the 'Templates' tab > 'List template':

Assignatura:Assignatura
Curs:Curs
Descripció:Descripció
Documents:Documents

Since I wanted to reproduce the particular layout in the databases at moodle.org, I modified the table in the 'List template' to look like the following:

Assignatura Curs Descripció Documents
Assignatura Curs Descripció Documents
##Edit## ##More## ##Delete## ##Approve##


I've managed to fix the alignment since the last screenshot, but I still get the headers repeated for every record:


db2

What am I doing wrong? The table headers are in the top row and yet they are repeated for every record in 'view list'. And, while we are at it, how do I do it so that the first one of the fields take you to the 'view single' when you click it? This is what happens in the three databases in moodle.org and I find it really useful. Again, any help you guys can give me with this will be greatly appreciated.

Josep M.
In reply to Josep M. Fontana

Re: Look of the database module

by Jan Dierckx -

Make sure you are using the list template. It indeed has a configurable number of fields. But above the fields is a header template and below it is a footer template. Both are only shown once for each list. Place the table and table header tags inside those two fields and they won't be repeated.

Inside header:

<table width="60%" border="1" align="center" cellspacing="0" cellpadding="0" bordercolor="#CCCCCC">
<tr><td>Bestand</td><td>Beschrijving<td>Datum</td><Bewerk></tr>

for each entry:

<tr><td>bestand</td><td>beschrijving<td>datum</td> <td>##More##</td></tr>

inside footer:

</table>

I think it is wiser to temporarily turn off the HTML editor doing this, because the database templates are not exactly compatible with the HTML editor. I answered this same message in the Dutch forum to another user who, like you, is quite experienced using computers. I have the feeling this whole database module was released too early.

In reply to Jan Dierckx

Re: Look of the database module

by Josep M. Fontana -
Duh! Of course. I was placing all the table code (headers and body) within the middle window ('Repeated entry'). Thanks for clarifying this, Jan.

It looks like you need all the HTML code for a complete table in both windows (header and repeated entry), though. If I do exactly what you say and don't start the table in the 'repeated entry' window with <table> and end it with </table>, it won't be accepted. Even if I place </table> in the footer. The moment I return to wysiwyg all the HTML code has disappeared. This is what you must mean when you say that the database templates are not compatible with the HTML editor.

What I did to solve the problem was to introduce a complete table in each window. But then the problem I had is that the different cells got resized according to their contents and wound up not being properly aligned. What I did then was to get a fixed width in pixels for every cell in both tables and that seems to work all right.  I wonder if it would be possible to use external CSS styles for all the layout in the database module. This would make things easier when you have to create many databases.

Thanks!

Josep M.