not sure if this should be in "How do I" or "Module development"...
please excuse my general ignorance of style sheets, themes, etc.
i'm working on customizing a module. i'm generating a table where the header row contains node titles, values that can be fairly long (roughly 3-10 words). the values within each regular cell will only be a single word or a number, so i don't need extra-wide columns. currently, my table is being displayed where each column's header string is printed in full, which makes the table excessively wide. i'd like to make the columns some fixed width, and force the header row to wrap the words (granted, in a taller row, but that's ok with me).
the code is basically like this:
$header = array();
$header[] = array('data'=> t('Name'));
// do an SQL query to fetch a bunch of node titles
$title_query = db_query( SELECT title FROM {node} ... );
while ($db_title = db_fetch_object($title_query)) {
$header[] = array('data' => $db_title->title);
}
$rows = array();
// do other queries and processing to fill in the rows...
$output .= theme('table', $header, $rows);
print theme('page', $output);
all the DB query stuff is working fine, i've got all the data i need, i just can't figure out how to make the table header columns a fixed width. in the part where i'm filling in the $header array with titles, i've tried:
$header[] = array('data' => $db_title->title, 'width' => '30');
or
$header[] = array('data' => $db_title->title, 'width' => "10%'');
i also tried permutations where i used 'id' or 'class' and tried to muck around in my theme's style.css file, but as i said at the top, i'm no style sheet expert, so i don't really know what i'm doing.
finally, out of desperation, i tried the following kludge:
$title_str = wordwrap( $db_events->title, 12, "