ich verwende das Modul "CSV-Datei / Ausgabe als Tabelle" (http://www.redaxo.de/165-Moduldetails.html?module_id=185) von Pixelworks und möchte es ein wenig abändern, auch weil es bisher nur für Version 3.x zur Verfügung steht, aber läuft auch unter 4.x.
Folgendes:
Ich füge eine Tabelle ein und möchte diese nun gestalten und zwar so, dass die Zeilen immer abwechselnd einen anderen Hintergrund haben. Dafür müsste ich CSS-Klassen vergeben aber mit der bisherigen Version ist dies nicht möglich.
Was müsste ich hier am Code verändern?
- Code: Alles auswählen
<?
//Define what you want the seperator to be, this could be new line, (\n) a tab (\t) or any other char, for obvious reasons avoid using chars that will be present in the string. Id suggest a comma, or semicolon.
$sep = ",";
//define file to read
$file = "REX_FILE[1]";
$uri = $REX['HTDOCS_PATH'];
$folder ="files/";
//read the file into an array
$lines = file($uri.$folder.$file);
//count the array
$numlines = count($lines);
//explode the first (0) line which will be the header line
$headers = explode($sep, $lines[0]);
//count the number of headers
$numheaders = count($headers);
$i = 0;
//start formatting output
echo "<table border = 1 cellpadding = 2><tr>";
//loop through the headers outputting them into their own <TD> cells
while($i<$numheaders){
$headers = str_replace("\"", "", $headers);
echo "<td>".$headers[$i]."</td>";
$i++;
}
echo "</tr>";
$y = 1;
//Output the data, looping through the number of lines of data and also looping through the number of cells in each line, as this is a dynamic number the header length has to be reread.
while($y<$numlines){
$x=0;
echo "<TR>";
while($x<$numheaders){
$fields = explode($sep, $lines[$y]);
$fields = str_replace("\"", "", $fields);
echo "<TD> ".$fields[$x]." </TD>";
$x++;
}
$y++;
echo "</TR>";
}
//close the table.
echo "</table>";
?>
Für jede Hilfe bin ich dankbar.

