DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: Readable name of your extension

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:Dirk Rottmar
Changed:2010-03-02T12:22:14
Classification:extensionkey
Description:The keywords help with categorizing and tagging of the manuals. You can combine two or more keywords and add additional keywords yourself. Please use at least one keyword from both lists. If your manual is NOT in english, see next tab "language" ---- forEditors (use this for editors / german "Redakteure") forAdmins (use this for Administrators) forDevelopers (use this for Developers) forBeginners (manuals covering TYPO3 basics) forIntermediates (manuals going into more depth) forAdvanced (covering the most advanced TYPO3 topics) see more: http://wiki.typo3.org/doc_template#tags ----
Keywords:keywords comma-separated
Author:Author Name
Email:your@email.com
Info 4:
Language:en

img-1 img-2 DBTable To HtmlTable -dbtable_to_htmltable

DBTable To HTML Table

Extension Key: dbtable_to_htmltable

Language: en

Keywords: Maps mySQL table(s) content to HTML table

Copyright 2000-2009, Dirk Rottmar, <dirk@rottmar.net>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.org

Table of Contents

EXT: Readable name of your extension 1

`Introduction 3 <#1.1.Introduction|outline>`_

What does it do? 3

Screenshots 3

`Users manual 4 <#1.2.Users%20manual|outline>`_

FAQ 4

`Administration 5 <#1.3.Administration|outline>`_

FAQ 5

`Configuration 6 <#1.4.Configuration|outline>`_

FAQ 6

Reference 6

`Tutorial 7 <#1.5.Tutorial|outline>`_

`Known problems 8 <#1.6.Known%20problems|outline>`_

`To-Do list 9 <#1.7.To-Do%20list|outline>`_

`ChangeLog 10 <#1.8.ChangeLog|outline>`_

Important guidelines 11

`HowTo update a manual to the new layout 12 <#2.1.HowTo%20update%20a %20manual%20to%20the%20new%20layout|outline>`_

`Issues with Open Office documentation for TYPO3 13 <#2.2.Issues%20w ith%20Open%20Office%20documentation%20for%20TYPO3|outline>`_

Inserting images 13

Paragraph styles 13

Linking 14

Meta data and updates 14

Help by documentation.openoffice.org 14

Introduction

What does it do?

This Extension renders mySQL data to a HTML tables without writing SQL queries and without coding HTML.

“DBTable To HtmlTable” collects data from one or more tables from any mySQL database which can be accessed from the web server and displays this data as HTML table, including column labels and pagination.

What is new in version 1.0?

According to user requests, the following features were implemented:

Cell data can be wrapped now. Version 1.0 and above makes it possible to layout individual table cells and generate hyperlinks.

Date and datetime fields can be formatted. The format of time-based data is only limited by the limitations of mySql.

Number fields can be rounded. The display of the amount of decimals is fully customizable.

Screenshots

Backend: configuration of sql table data

img-3

Backend: database settings

img-4

Backend: page pagination settings

img-5

Backend: character conversion settings

img-6

Frontend: the html table rendered with the above settings

img-7

Users manual

((generated))

Requirements:

This extensions does not rely on other extensions.

Installation:

No special installation process is required, just use the normal way via the TYPO3 extension manager.

Usage:

In order to display database content in a html table you need to know the following:

The database host (is mandatory) . This can be any mySQL database host at any place in the world. You just have to make sure, that the server, where your Typo3 is installed, can connect to this mySQL server.

The database port. This entry is mandatory, even if your mySQL database listens to the default port, which is usually 3306 for mySQL version 5.x servers.

The database name (is mandatory).

The database user (is mandatory).

The database user's password (is mandatory).

The table and field names you want to be rendered as html table. This is quite simple, if you just want to display the content of a single table and a little bit more tricky, if you want to display the content of joined tables.

You may want to convert the retrieved characters from the database. If your characters look somehow damaged, e.g. german umlauts are not displayed correctly or you just see funny dots instead of well formated chinese characters, you should play around with the character conversion settings.

Example 1 – display data from a single table

You want to display data from the following “person” table.

img-8

The field “id” and the filed “zip” should not be displayed

The other fields should be diplayed in the order lastname, firstname, street and city

The data should be sorted alphabetically by the field firstname

After you inserted all the necessary data in section “Database Settings” you fill out section “Field Mapping” with the following data:

“Mastertable” is person

“Field Description” is...

::

a

{table=>"person";field=>"id";label=>"Adress Id";display=>"no";}
{table=>"person";field=>"lastname";label=>"Lastname";sort=>"asc";}
{table=>"person";field=>"firstname";label=>"Firstname";}
{table=>"person";field=>"street";label=>"Street";}
{table=>"person";field=>"zip";label=>"Zip Code";display=>"no";}
{table=>"person";field=>"city";label=>"City";}

The attributes will be described later, important for now is, that

Every field-description entry must be wrapped with curly braces “{” and “}”

All values should be wrapped with double quotes.

Name-value pairs are separated by semicolons “;”

Example 2 – display data from joined tables

You want to display data from the following tables: “person”, “country” and adresstype

img-9 You want to display the following html-table:

img-7

The columns with the labels “Lastname”, “Firstname”, “Street”, “Zip- Code” and “City” can be fount in the table “person”.

The column labeled with “Country” is the column “name” in the table “country” and the column labeled with “type” is the column “name” from the table “adresstype”.

After you inserted all the necessary data in section “Database Settings” you fill out section “Field Mapping” with the following data: “Mastertable” is person

The tables “country” and “adresstype” are joined tables (actually sql left outer joins). As you can see above, the relationship between the “person” and the “country” table is many to one. The dbtable_to_htmltable syntax for joining these tables via the country primary key column “id” and the person foreign key column “country_id” is...

::

a

{table=>"person";field=>"country_id";jointable=>"country";joinfield=>"id";}

As you can see, the attribute “table” is the same as the “mastertable” entry above.

The same happens with the “adresstype” table:

::

a

{table=>"person";field=>"adresstype_id";jointable=>"adresstype";joinfield=>"id";}

Although you don't need to write any sql, you might be interested in some background information:

The actual sql-query would look like this...

select * from person

a

select * from person

left outer join country on person.country_id = country.id

left outer join adresstype on person.adresstype _id = adresstype.id

The complete “Field Description” for displaying the above html-table is:

::

a

{table=>"person";field=>"id";label=>"Adress Id";display=>"no";}
{table=>"person";field=>"lastname";label=>"Lastname";sort=>"asc";}
{table=>"person";field=>"firstname";label=>"Firstname";sort=>"asc";}
{table=>"person";field=>"street";label=>"Street";}
{table=>"person";field=>"zip";label=>"Zip Code";}
{table=>"person";field=>"city";label=>"City";}
{table=>"person";field=>"country_id";jointable=>"country";joinfield=>"id";display=>"no";}
{table=>"country";field=>"name";label=>"Country";}
{table=>"person";field=>"adresstype_id";jointable=>"adresstype";joinfield=>"id";display=>"no";}
{table=>"adresstype";field=>"name";label=>"Type";}
Example 3 – filtering data according to your personal criterias

You don't want to display the hole table content – to show just parts of it, use the following example.

Using a filter (e.g. “New York”) for field “city” in table “person” would look like this:

::

a

[]
{table=>"person";field=>"city";label=>"City";filter=>'New York';}
[...]

Filtering for varchar-fields makes the single quotes mandatory. You should avoid them if filtering for number-fields. Play around a little if you want to use SQL-wildcars like “%” or placeholders like “.” Any valid SQL-character should work.

Example 4 – layouting cell data

Not every cell should look the same. Some data should be colored, emphasized, underlined, stroked or whatever.

You may use any valid HTML-code to reach the target (please have a look at the reserved characters “{” and “}” information below).

The field description attribute is:

wrap=>"<!--<span style="color: blue;font-weight: bold;">|</span>//-->";

Example for coloring and emphasizing a certain cell:

::

a

[...]
{table=>"person";field=>"city";label=>"City";wrap=>"<!--<span style="color: blue;font-weight: bold;">|</span>//-->";}
[...]

The content of the wrap-attribute must be enclosed in XML-style character data comments. Since you want to use every character to layout your cell(s), the dbtable_to_htmltable parser has to know where your wrap starts and ends. If you want to customize individual cells, don't forget that! The wrap must be enclosed with <!-- [...] //-->

The pipe character (“|”) - as usual in Typo3 – is the placeholder for the cell value. Unlike Typo3, you may use it in one wrap context as often as you like.

Reserved characters are “{” and “}” and must not be used within the wrap attribute.

Example 6 – formatting date and datetime output

Date and datetime information is often stored in a format which does not satisfy the user's needs. Because of this, dbtable_to_htmltable gives you full control about date formatting.

The field description attributes – we need 2 of them - for formatting date and datetime columns (timestamp should also work) is the following:

type=>" datetime ";

format=>" [...mySql-format attributes...] ";

Example of formatting a datetime column for german speaking users with the example cell-output

“27.02.2010, 23:59:58 Uhr” :

::

a

[...]
{table=>"person=>;field=>"contact_date";label=>"First contact";type=>"datetime";format=>"%d.%m.%Y, %k:%i:%s Uhr";}
[...]

You may use all date-format specifiers described in the mysql documentation which can be found at `http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html <http://dev.mysql.com/doc/refman/5.1/en/date-and-time- functions.html>`_

In the above example the following specifiers were used:

%d => Day of the month, numeric (00..31)

%m => Month, numeric (00..12)

%Y => Year, numeric, four digits

%k => Hour (0..23)

%i => Minutes, numeric (00..59)

%s => Seconds (00..59)

Example 7 – rounding numbers

Rounding numbers is especially useful if your field is of type double or float and the decimals should not be displayed. It can also be used if you want to present integer-values with suffixed “.00”

The field description attributes – we need 2 of them - for rounding numbers is the following:

type=>" number ";

*decimals=>"* *[...number of decimals to be displayed...]* *";*

Example of rounding a double or float value with only 1 decimal to be displayed.

::

a

[...]
{table=>"person=>;field=>"salary";label=>"Monthly Salary";type=>"number";decimals=>"1";}
[...]
Attributes overview
display

Attribute

display

Remark

Decides wheter this column will be displayed in the HTML table

Mandatory

No

Default Value

display=>”yes”

Example

display=>”no”
field

Attribute

field

Remark

The column name of the query table

Mandatory

Yes

Default Value

Example

field=>”mycolumn”
filter

Attribute

filter

Remark

Filter columns according to string or integer values.

Please note:

- For filtering for string-values use single quotes within the double quotes

- For filtering for number values use no single quotes

- More than one number will be separated by commas

Mandatory

No

Default Value

Example

Filter your adress data for persons living in New York

filter=>'New York'

Filter your adress data for the person with the id = 2 in table “person”

filter=>”2”

Filter your adress data for the persons with the id = 2, 4 or 5 in table “person”

filter=>”2,4,5
jointable

Attribute

jointable

Remark

The table name of the joined table. Will always be joined by the mastertable. Mastertable and table attribute must be identical.

Mandatory

No

Default Value

Example

jointable=>"myjointable"
joinfield

Attribute

joinfield

Remark

The join column of the join table (in most cases this will be the foreign-key column)

Mandatory

No

Default Value

Example

joinfield=>"myjoinfield"
label

Attribute

label

Remark

The label of the column in the HTML table.

Please note: If there is no label attribute at all, the HTML table header will not be generated.

Mandatory

No

Default Value

Example

lable=>”My Column”
sort

Attribute

sort

Remark

The sorting of this column. Every column can have a sort attribute. The first occurrence is stronger than the second, and so on. Sorting can be ascending or descending.

Mandatory

No

Default Value

sort=>”none”

Example

sort=>”asc”

...or...

sort=>”desc”
table

Attribute

table

Remark

The query table

Mandatory

Yes

Default Value

Example

table=>”mytable”
wrap

Attribute

wrap

Remark

Wraps cell content

Mandatory

No

Default Value

Example

wrap=>"<!--<span style="color: blue;">|</span>//-->";
type

Attribute

type

Remark

Tells the parser the type of the column in order to format a datetime- cell or round a number-cell.

Mandatory

Yes, if used in conjunction with attribute “format” or “decimals”

Default Value

Example

type=>"datetime";format=>"%d.%m.%Y, %k:%i:%s Uhr";

...or...

type=>"number";decimals=>"1";
format

Attribute

format

Remark

Datetime formatting specifier

Mandatory

No, but must be used together with attribute “type”

Default Value

Example

type=>"datetime";format=>"%d.%m.%Y, %k:%i:%s Uhr";
decimals

Attribute

decimals

Remark

Specifies the number of decimals displayed when rounding numbers

Mandatory

No, but must be used together with attribute “type”

Default Value

Example

type=>"number";decimals=>"1";
CSS

The output table will be rendered automatically by the extension. If you declared at least one “label” attribute in the field-description section, a table head will be generated. The table can be formated with CSS. The example below shows all possibilities to declare the table layout. These styles render the table in the above screenshot:

::

a

/*** the table ***/
.tx-dbtabletohtmltable-pi1 > table{
    border: 0px solid #cccccc;
    border-collapse: collapse;
    margin: 0;
    padding: 0;
    font-size: 0.8em;
    width: 100%;
}
/*** cell in table-head ***/
.tx-dbtabletohtmltable-pi1 > table > thead > tr > td {
    border: 0px solid red;
    font-weight: bold;
    padding: 0.4em;
    border: 1px solid #000000;
    color: #ffffff;
    text-align: center;
}
/*** table-head row ***/
.tx-dbtabletohtmltable-pi1 > table > thead > tr {
    background-color: #ff8700;
}
/*** table body row even-class ***/
.tx-dbtabletohtmltable-pi1 > table > tbody > tr.even{
    background-color: #ff9f33;
}
/*** table body row odd-class ***/
.tx-dbtabletohtmltable-pi1 > table > tbody > tr.odd{
    background-color: #ffffff;
}
/*** cell in table-body ***/
.tx-dbtabletohtmltable-pi1 > table > tbody > tr > td{
    padding: 0.2em;
    border: 1px solid #000000;
}
/*** pagination/navigation box ***/
.tx-dbtabletohtmltable-pi1 > .fullnav{
    border: 1px solid #000000;
    font-size: 0.8em;
    width: 100%;
    text-align: center;
    margin: 5px 0 5px 0;
    padding: 5px 0 5px 0;
    background-color: #ff8700;
}
.tx-dbtabletohtmltable-pi1 > .fullnav > .entryFirst{
    border: 1px solid #cccccc;
    margin: 5px 5px 5px 5px;
    padding: 3px 3px 3px 3px;
}
.tx-dbtabletohtmltable-pi1 > .fullnav > .entryPrev{
    border: 1px solid #cccccc;
    margin: 5px 5px 5px 5px;
    padding: 3px 3px 3px 3px;
}
.tx-dbtabletohtmltable-pi1 > .fullnav > .entryCurrent{
    border: 1px solid #cccccc;
    margin: 5px 5px 5px 5px;
    padding: 3px 3px 3px 3px;
}
.tx-dbtabletohtmltable-pi1 > .fullnav > .entryNext{
    border: 1px solid #cccccc;
    margin: 5px 5px 5px 5px;
    padding: 3px 3px 3px 3px;
}
.tx-dbtabletohtmltable-pi1 > .fullnav > .entryLast{
    border: 1px solid #cccccc;
    margin: 5px 5px 5px 5px;
    padding: 3px 3px 3px 3px;
}

For download the CSS as file, please go to http://www.medianet.de/dbtabletohtmltable

FAQ

  • Question: I filled out the database settings and the field descriptions, but still get an error message indicating a problem with the query. What's the best way to solve the problem.
  • Answer: Most likely you got have a wrong table, field, jointable or joinfield name in the field description section. If you want to query a complex parent-child table structure, I recommend to start with a simple scenario and work towards a more complex field-description definition.
  • Question: I have a very complex database model to display as HTML table. Is it possible to define such kind of complexity in the field description?
  • Answer: The answer is simple. Yes and no! As long as you have a parent-child relationship and “mastertable” is always involved, it should be possible to display it as a HTML table. In other words, as long as you could query it with one mastertable and left outer joins in sql, this extension will work.
  • Question: Is it possible to make the columns sortable for the user after the table is rendered?
  • Answer: It's currently not possible, but should be in future versions of the extension.
  • Question: Why is section “field description” so cryptic? Wouldn't it be easier to use some kind of wizard to define the necessary attributes.
  • Answer: Yes, it would be much easier. Until today, I did not find a way to implement the typo3 wizard framework for flexform applications. As soon as it will be possible, I will implement it.
  • Question: Did you receive any help during the development?
  • Answer: Yes, actually PS_Pagination from http://phpsense.com helped me a lot concerning the pagination features. I had to modify some core code from the lib, but it still was very helpful and saved a lot of work.
  • Question: Why did you develop this extension?
  • Answer: I just wanted to get a feeling for developing Flex-Form based extensions and this little project gave me an impression.
  • Question: If I want to know more about you, your company or this extension, what can I do?
  • Answer: Just have a look at the Medianet website, http://www.medianet.de or write a message to dirk@rottmar.net.

Known problems

So far not known

To-Do list

  • Field-Description wizard implemenation
  • Improving exception-handling

14