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.
Created: | 2007-08-14T11:09:38 |
---|---|
Changed: | 2007-08-14T11:23:03 |
Email: | tim.wentzlau@auxiliorl.com |
Info 2: | |
Info 3: | |
Info 4: |
Extension Key: auxdataviewer
Copyright 2006-2007, tim.wentzlau@auxiliorl.com, <tim.wentzlau@auxiliorl.com>
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.com
((generated))¶
Table of Contents¶
EXT:DB App builder 1
Introduction 1
What does it do? 1
Users manual 2
Requirements 2
Overview of the process 2
What is going on 2
Defining the tables 3
Defining Data Views 3
Front end rendering 8
Administration 10
Master/slave relations between grids and records 10
Styling the views 10
Static extension template TS properties 10
Support for multiple languages 11
Extending your application with Typo Script in DAB views 11
Extend TCA for your tables 13
Extending your DAB application with PHP 13
Tutorial 14
General information 14
Defining tables 14
Defining the views 22
Creating page structure 31
Known problems 34
To-Do list 34
Changelog 34
Introduction¶
What does it do?¶
DB App Builder (DAB) makes it is possible to create DB applications in Typo3 without the need to write extensions in PHP or greatly reduces the needs for PHP programming. It is designed as a RAD tool that makes the default DB coding trivial and fast. DB App Builder extents the Extension Kick starter with extra an extra section where it is possible to define FE data views that are rendered with the FE content element Data View (a part of this extension).
Features in DAB
- DB grids and lists with master/slave relations to other grids and input forms on the same page or other pages.
- Ajax support where master/slave relations are handled without page reload.
- Graceful degradation in browsers that do not support Javascript and Ajax, all most all functionality is retained but with page reload.
- Support all features that are possible to define in TCA.
- Support for FE access control.
- FE editing, as forms or directly in DB grids.
- Support for events like onSelect and onCreate where SQL statements and PHP code may be executed.
- The created DB applications are possible to upload to TER for sharing with the Typo3 community.
- Extensive support for CSS.
Example of a small DAB application
Users manual¶
Requirements¶
Before you are able to use DAB you must install the extension Extesnion Kickstarter and learn how to define tables and relations. There exists several videos about the kickstarter on typo3.org but Extension Kickstarter episode III is the most important.
Overview of the process¶
1. Define the tables
With DAB you start as normal in the Extension Kickstarter by defining the tables.
2. Define the data views
After tables and relations are created you move on to define the data views in the Data view section. A data view is a set of definitions that specify how tables should be presented in the front end. In a data view you specify the fields that should be visible, sort order and master/slave relations between data views.
3. Render the Data views in front end
Each data view is rendered in the front end with the plug-in Data view (a part of this extension). By placing all views on one or more pages you are making the actual implementation of your DAB application.
What is going on¶
What DAB does behind the scene when rendering the data views in the front end is basically to create the SQL query that fetch the data from the table specified in the data view. The construction of the SQL query is based on the table definitions as they are stored in TCA and the settings of a data view. The constructed SQL query is executed and the result set is applied to a HTML template.
Defining the tables¶
When creating a DAB application the tables and relations are defined as normal in the extension kick starter.
Defining Data Views¶
The next step is to create the data views of each table. Data views are defined in the Data view section click on the plus next to the section title and the settings for a single data view of one table could be created.
Data view settings¶
Name¶
Property
Name
Description
The name of the data view is use to identify the view.
Description¶
Property
Description
Description
A short description of the data view.
View Type¶
Property
View Type
Description
How should the view be rendered. As a list, grid, form/record or dropdown.
Data set¶
Property
Data set
Description
Select the table that should be viewed
Fields¶
Property
Fields
Description
Select the fields that should be visible. The fields appear in the same order in the front end.
External fields¶
Property
External fields
Description
Fields that are relations to other tables uses by default the defined label field in the foreign table.
If you want to display another value in the foreign table it is possible to define it here as an external field.
Enter the name of the table where the foregin field should be fetched from and the name of the new field. Click on Add.
Enter the keyfield (normally uid) the field to use in the foreign table and the field in this view that controls the releation.
Calculated fields¶
Property
Calculated fields
Description
Here it is possible to define extra fields that may contain sql expressions.
Alternativly it is possible to make calculations in PHP events (see later in this documentation)
Default sort field¶
Property
Default sort field
Description
By default DAB uses the field defined as sort field in TCA for the table, but you can change it here.
Default group by¶
Property
Default group by
Description
Select the field you want to group by.
Category field¶
Property
Category field
Description
In list view you may specify a field that is used as category header. The resulting SQL then sort the result set by the category field. In the list output the values of the category is used as header.
FE user field¶
Property
FE user field
Description
Select a filed that have a relation to the fe_user table. The selected field will automatically be bound to the current FE user when FE users create records.
You may combine this setting with the FE Owner only property in the FE view in order to show only records that are owned by the current FE user.
Filter¶
Property
Filter
Description
Additional expressions that goes into the where part of the generated SQL query
Master views¶
Property
Master views
Description
In this section you specify the views that may control this view this defines the master/slave relations.
Select the view that should control this view click Add.
Select the fields that makes up the relation (defaults is based on TCA)
Default action¶
Property
Default action
Description
Select the action that is executed when a FE user clicks on an item in the list grid or dropdown.
Template¶
Property
Template
Description
If the default template does not fulfill your requirements you may make your own and specify it here
Style prefix¶
Property
Style prefix
Description
This values is appended to the main div tag of the rendered DAB component. It makes it possible to make specialized CSS styling
TS¶
Property
TS
Description
Here it is possible to make extended configuration of the data view see later this manual for an in depth coverage of this field.
Default FE view settings¶
In this section it is possible to define the default values in the FE Data View plug-in when a view is selected in the plug-in.
Visible fields¶
Property
Visible fields
Description
Select the fields that should be visible in the view.
Editable fields¶
Property
Editable fields
Description
Select the fields that are editable.
If a field is not defined as visible only editable the field is only visible when the view is in edit mode.
Show Header¶
Property
Show Header
Description
When set in Grid mode the column headers are displayed.
When set in Single record mode the field names are displayed.
Grid buttons¶
Property
Grid buttons
Description
What buttons should be displayed for the grid or list
Row buttons¶
Property
Row buttons
Description
What buttons that should be displayed for a row in a grid. Normally only one of the edit buttons should be displayed.
Edit sets a slave view in edit mode.
Edit row activates in line editing directly in the grid.
Edit record switches from grid view to a form where it is possible to edit
The edit buttons are only shown if the FE user are allowed to edit the records.
Grid height¶
Property
Grid height
Description
Defines the height of the grid.
Grid header height¶
Property
Grid header height
Description
Defines the height of the header of the grid. Unfortunally it is not possible to define this in CSS alone as scrolling in the grid needs some calculation to work in some browsers. As a result you have set the height here and in the CSS.
Image width¶
Property
Image width
Description
Default width of images
Image height¶
Property
Image height
Description
Default height of images
Max grid/list rows¶
Property
Max grid/list rows
Description
Maximum number of rows in a grid. If the number of records in a query is greater that this value the Navigator is activated.
Show empty values¶
Property
Show empty values
Description
If set empty values are shown in single record.
Show label field as header¶
Property
Show label field as header
Description
If the view mode is single record the label field is shown as a header of the record and the page title is set to the value of the label field.
Edit fields inline¶
Property
Edit fields inline
Description
Forces inline edit of rows in grid mode.
Use Ajax¶
Property
Use Ajax
Description
Activates Ajax support.
Activate only Ajax when needed. Ajax support gives a little extra page generation overhead.
Public edit¶
Property
Public edit
Description
Allows all fe-users to edit and update the view. In this mode chacpta is automatically turned on to prevent spam.
View only FE owner records¶
Property
View only FE owner records
Description
When set only records that are owned by the current FE user are displayed. For this to work a FE owner field must be defined in the view (see above).
When you have finished your work in the kick starter you should write and install your extension.
Front end rendering¶
To display a data view you should use the FE plug-in Data view (a part of this extension).
Include static extension template¶
The first thing to do is to select the static template for the DAB view. This may be done in your main TS-template, select the “Data view (auxdataviewer)” template.
FE content element¶
Go to the page where you want to display the data view and insert the Data view content element.
Select the view name and fill in fields in the fields on the tabs.
Definition of properties¶
View¶
sheet
View
Property
View name
Description
((Unknown Property))¶
sheet
Property
Lookup records in
Description
((Unknown Property))¶
sheet
Property
Create records in
Description
((Unknown Property))¶
sheet
Property
Use Ajax
Description
Activates Ajax support.
Activate only Ajax when needed. Ajax support gives a little extra page generation overhead.
((Unknown Property))¶
sheet
Property
Show debug info
Description
Template¶
sheet
Template
Property
Template file
Description
((Unknown Property))¶
sheet
Property
Style prefix
Description
Layout¶
sheet
Layout
Property
Show Header
Description
When set in Grid mode the column headers are displayed.
When set in Single record mode the field names are displayed.
((Unknown Property))¶
sheet
Property
Show navigator
Description
In grid and list mode the navigator is shown .
((Unknown Property))¶
sheet
Property
Grid buttons
Description
What buttons should be displayed for the grid or list
((Unknown Property))¶
sheet
Property
Row buttons
Description
What buttons that should be displayed for a row in a grid. Normally only one of the edit buttons should be displayed.
Edit sets a slave view in edit mode.
Edit row activates in line editing directly in the grid.
Edit record switches from grid view to a form where it is possible to edit
The edit buttons are only shown if the FE user are allowed to edit the records.
((Unknown Property))¶
sheet
Property
Grid height
Description
Defines the height of the grid.
((Unknown Property))¶
sheet
Property
Grid header height
Description
Defines the height of the header of the grid. Unfortunally it is not possible to define this in CSS alone as scrolling in the grid needs some calculation to work in some browsers. As a result you have set the height here and in the CSS.
((Unknown Property))¶
sheet
Property
Image width
Description
Default width of images
((Unknown Property))¶
sheet
Property
Image height
Description
Default height of images
((Unknown Property))¶
sheet
Property
Max grid/list rows
Description
Maximum number of rows in a grid. If the number of records in a query is greater that this value the Navigator is activated.
((Unknown Property))¶
sheet
Property
Show empty values
Description
If set empty values are shown in single record.
((Unknown Property))¶
sheet
Property
Show label field as header
Description
If the view mode is single record the label field is shown as a header of the record and the page title is set to the value of the label field.
((Unknown Property))¶
sheet
Property
Edit fields inline
Description
Forces inline edit of rows in grid mode.
Sub page¶
sheet
Sub page
Property
Single view
Description
Page to change to when viewing a single record. DAB will change to this page if the View Type is List and the default selection is View or items in the list have a view button.
((Unknown Property))¶
sheet
Property
Print single
Description
Page to change to when viewing a single record. DAB will change to this page if the View Type is List or Grid and the default action is print or items in the list have a print button.
((Unknown Property))¶
sheet
Property
Print list
Description
Page to change to when view a list and the user click on the grid button print.
((Unknown Property))¶
sheet
Property
Edit single
Description
Access¶
sheet
Access
Property
Public edit
Description
Allows all fe-users to edit and update the view. In this mode chacpta is automatically turned on to prevent spam.
((Unknown Property))¶
sheet
Property
View only FE owner records
Description
When set only records that are owned by the current FE user are displayed. For this to work a FE owner field must be defined in the view (see above).
((Unknown Property))¶
sheet
Property
Allow edit
Description
Only fe users that belongs to selected FE usergroups are allowed to edit records.
((Unknown Property))¶
sheet
Property
Description
Administration¶
DAB is designed to be a RAD tool, but also allows more fine grained control extending functionality with Typo Script and support for PHP. Finally the template files that are used supports styling with CSS and allows styling of all data views and single views.
Upgrading from versions previous to version 1.0.0¶
If you have installed an older version of DAB you may need to perform several steps when upgrading to version 1.0.0.
First of all you have to run the Update tool in the extension manager in order to convert old DAB plugin content elements to the new Data viewer content element.
Next you will have to go thru all views defined in the kickstarter to set new options and check that master views ect. Are converted correctly.
Finally you have to go thru all views on FE pages to set new functionality there.
I am sorry for the inconvenience but these changes where needed in order to gain the benefit of ease of use.
Master/slave relations between grids and records¶
Master/slave relations between grids and records are setup in the Data view section in the kickstarter. When rendered in the front end DAB depends on the evaluation order of the components on a page to generate the master slave relations.
This means that a master must be evaluated before a slave when a page is generated. In other words master grids should generally be on top of a slave. If Templa voila is used as pages templating system a pages is generated by the order of fields in the template DS.
Styling the views¶
The default template that comes with the extension is based on CSS styling. The DAB components are designed so they can share styles but also allows you to style each component individually. The default template is located in EXT:aux_dataviewer/res/template.tmpl and the default style sheet is located in EXT:aux_dataviewer/static/setup.
To allow for flexiable styling each row, button field etc. has several css class names. As an example a record field in a grid may have the following classes: dvGridRow dvField dvType_#TYPE# dvField_#NAME# dvEven
Where #TYPE# is substituted with the field type and #NAME# is substituted with the name of the field.
Use FireFox and FireBug to examine the active styles.
Static extension template TS properties¶
charset¶
TS field
charset
Description
The charset that should be used with AJAX
default
UTF-8
disableAJAX¶
TS field
disableAJAX
Description
Disables AJAX regardless of settings in the FE views. May be useful if security flaws are discovered in XAJAX.
default
false
template¶
TS field
template
Description
File that holds the template
default
Standard template that comes with the extension.
dateFormat¶
TS field
dateFormat
Description
Format of date fields
default
%d-%m-%Y
timeFormat¶
TS field
timeFormat
Description
Format of time fields
default
%H:%M
dateTimeFormat¶
TS field
dateTimeFormat
Description
Format of dateTime fields
default
%d-%m-%Y %H:%M
timeSecFormat¶
TS field
timeSecFormat
Description
Format of timeSec fields
default
%H:%M:%S
buttons¶
TS field
buttons
Description
Defines the icon images or text on the buttons in the views.
The buttons that could be used are:
edit, rowedit, recedit, print, view,new, delete, start,end, next, prev, sortDesc, sortAsc, sortBullet, select, go, update, back.
Each button has two fields .icon and .text.
.icon takes precedence over .text and defines the path to the buttons icon.
.text holds a textual representation of a button.
Example :
plugin.tx_auxdataviewer_pi1{
buttons{
edit.icon=EXT:auxdataviewer/res/icons/buttons/edit.png
end.text=>|
}
if the image files are PNG type DAB will apply the needed filters in IE 6 and below.
default
indicators¶
TS field
indicators
Description
Specifies the AJAX indicator to show when the views update.
It is possible to use graphical or textual indicators.
Possible indicators are grid, list and single.
example
plugin.tx_auxdataviewer_pi1{
indicators{
grid.icon=EXT:auxdataviewer/res/icons/indicators/ajax-loader-gray.png
single.text=Updating record....
}
If you want an indicator that matches your colors and design you may find http://www.ajaxload.info useful.
default
Support for multiple languages¶
DAB supports the language features in the extension kickstarter. If you specify different table field labels for each language in the kickstarter and set the config.language in the setup part of your (main) ts-template, then DAB automatically fetches the field labels for the selected language.
Extending your application with Typo Script in DAB views¶
It is possible to let DAB build more advanced SQL queries by adding Typo Script to a Data View in the Extension Kick starter.
Notice You can not specify any of these typo script values to normal Template extensions. The typoscript that is described below is only valid in the TS section of the data view in the Extension kick starter
sql¶
distinct¶
Property
distinct
Data type
Boolean
Description
Adds the distinct keyword to the SQL query
Example:
sql.disctinct=true
Default
false
fields¶
Property
fields
Data type
String
Description
A list of extra fields that should be included in the query these fields are not visible in the view as they goes directly into the sql query. Are reachable in PHP classes.
Example:
sql.fields=field1, field2
Default
ExtraFields¶
(deprecated, is build into the kickstarter now)
The extraFields section works pretty much like TCA here it is possible to define additional fields in the data view. These fields are all lookups to other tables. Also look at the extra fields section in the data view section in the kickstarter.
label¶
Property
label
Data type
string
Description
Name of the field
Default
If omitted DAB will use the name of the foreign field defined in TCA
type¶
Property
type
Data type
string
Description
Only allowed value right now is select
Default
foreignTable¶
Property
foreignTable
Data type
string
Description
Name of foreign table
Default
foreignField¶
Property
foreignField
Data type
string
Description
Name of field to include
Default
If omitted the label field for the foreign table is used.
KeyField¶
Property
KeyField
Data type
String
Description
Name of the field in this views record that should be used for lookup.
Default
expr¶
Property
expr
Data type
String list
Description
A list of the following values:
required,
uppder,
lower
Default
visible¶
Property
visible
Data type
Boolean
Description
Is the field visible in the view. If false the extra field could be used in filter values ect.
Default
true
Example:
extraFields {
artistlink{
label=Artist web site
type=select
foreignTable=tt_auxcdcollection_artist
foreignField=website
keyField=artist
visible=true
}
}
Events¶
It is possible to define a kind of TS events that is executed when a record is created (onNew), updated(onUpdate), deleted (onDelete) or selected (onSelect). All these events will execute additional SQL queries besides from the main SQL query. The intension with these events are to support updates in other tables based on user selection. Currently these SQL functions supported setField, selectInto and deleteFrom.
Events are defined in the following way
events{
onNew{
10{
function=setField
field=feuser
value=###feuser###
}
}
}
Functions¶
setField
Will execute a SQL query:UPDATE table SET field = value WHERE condition
table¶
Property
table
Data type
string
Description
Table to update
Default
The table defined for this view
conditon¶
Property
conditon
Data type
string
Description
Where clause it is possible to use the markers:
###masteruid###
###feuser###
###uid###
Default
Uid=###uid###
value¶
Property
value
Data type
string
Description
A value or one of the markers
###masteruid###
###feuser###
###uid###
Default
field¶
Property
field
Data type
string
Description
Field to update
Default
masterView¶
Property
masterView
Data type
string
Description
View to control the the marker
###masteruid###
If masterView is set DAB will substitute ###masteruid### with the dvid value of the masterView.
See section about Cursors for the meaning of a views dvid
Default
If not set ###masteruid### will be substituted with the value of this views dvid.
selectInto
Will execute a query:INSERT INTO dstTable (pid,tstamp,crdate,cruser ... dstFields ) SELECT srcFields FROM srcTable WHERE condition
dstTable¶
Property
dstTable
Data type
string
Description
Table to insert rows into
Default
srcTable¶
Property
srcTable
Data type
string
Description
Table to get rows from
Default
dstFields¶
Property
dstFields
Data type
string
Description
Fields to update in the destination table
Default
srcFields¶
Property
srcFields
Data type
string
Description
Fields to get values from in the source table
Default
condition¶
Property
condition
Data type
string
Description
Condition to select rows from the source table. It is possible markers
###masteruid###
###feuser###
###uid###
Default
MasterView¶
Property
MasterView
Data type
string
Description
View to control the the marker
###masteruid###
If masterView is set DAB will substitute ###masteruid### with the dvid value of the masterView.
See section about Cursors for the meaning of a views dvid
Default
if not set ###masteruid### will be subsitutet with the value of this views dvid.
deleteFrom
Will execute the query:DELETE FROM table WHERE condition
table¶
Property
table
Data type
string
Description
Table to delete rows from
Default
condition¶
Property
condition
Data type
string
Description
Condition that should control which rows to delete from the table.
Default
masterView¶
Property
masterView
Data type
string
Description
View to control the the marker
###masteruid###
If masterView is set DAB will substitute ###masteruid### with the dvid value of the masterView.
See section about Cursors for the meaning of a views dvid
Default
if not set ###masteruid### will be subsitutet with the value of this views dvid.if not set ###masteruid### will be subsitutet with the value of this views dvid.
Extend TCA for your tables¶
Normal practice is to define all additional TCA settings in the file tca.php in your extension. Because the extension kickstarter rewrites tca.php you may loose these extra settings. If you need to add extra TCA information use the file dab_tca.php in the ext:dab/user/dab_tca.php this file is saved from rewriting in the kickstarter.
Example of how to add extra TCA information:
$TCA["tx_auxproductsupport_prodversion"]["ctrl"]["label_alt"] = 'version';
$TCA["tx_auxproductsupport_prodversion"]["ctrl"]['label_alt_force' ]=true;
Extending your DAB application with PHP¶
DAB supports PHP by automatically creating a class for each data view that is created in the Extension Kickstarter. These classes are located under EXT:your_extension/DAB/user/views. The methods in these classes are called as events and currently DAB supports the following events: onBeforeInsert, onAfterInsert, onBeforeUpdate, onAfterUpdate, onSelect onDelete and onGetText.
Parameters and return values are described in the PHP class files.
IMPORTANT
DAB is a RAD tool and kindly saves your modified PHP view class files from being deleted if you want to define new tables and data views in the Extension kick starter.
Tutorial¶
This tutorial demonstrates how to create the extension CD collection 2 it is possible to download it from TER (auxcdcollection).
When creating a DAB application you start as normal in the kickstarter by defining general information and tables.
General information¶
Fill in the name of the extension, author etc.
Very important is to enter that this extension depends on DAB the extension key for DAB is auxdataviewer. If you don't and uploads this extension to TER other Typo3 users may come in troubles if they have not installed DAB.
Defining tables¶
The next step is to define the tables that should be used in our DAB application. This is done as normal in the tables section. In our application we need the tables artist, cd and category.
Artist table
Category Table
Define the music category table
CD Table
Defining the views¶
The next step is to create the views that is done in the DataView section in the Kickstarter menu.
Artist View
CD view
In the picture above the masterview is created by selection the name of the master view in the “Add new view master” and then click add:
The next step is to match the fields that makes up the releation
After that select the default settings for the view
CD info view
Notice above the external field website. It is defined selecting the view and enter a name
Next match the relation by selecting artist in the Master field and website in Label field
Next fill in the default settings notice that the external field now appears in the field list.
All tables and views are defined the next step is to create the extension and install it.
Click on the button View Result
Click write to create the extension.
Install the extension.
Creating page structure¶
Before we are able to view any thing in FE we need to create a page to show in FE and a sys folder to hold the records.
In the DAB data folder you should create some records for category, artist and cd. In the example below i have only created CD records for U2.
On the FE page you should insert the content element Data view in order to see the data views defined in the extension kickstarter.
The artist view
The CD view
the Cd detail view
In templavoila it should look something like that
And in the front end it should look like this.
Thats all it takes to make a DAB application.
Known problems¶
- No support for RTE when using AJAX
To-Do list¶
- Extended support for PHP so it is possible to access DAB information in the normal FE plug-ins
- Inline master/slave details in grids
- Tree component
- support for DAM
Changelog¶
Version 0.0.1
Initial upload
version 0.0.2
updated the manual with a tutorial.
Version 0.0.3
Wrong manual uploaded.
Version 0.0.4
Fixed issue with wrong TCA information that caused trouble in BE.
Version 0.0.5
- Ajax support
- Full TCA support
- new templates with better CSS support
- Extended Dataview section in Kickstarter
version 1.0
- converted to a content element.
- most options may now be controlled by the content element.
- Default template for grids works in IE, FireFox, Opera, Safari, Konqueror.
- External and calculated fields may be defined in the kickstarter.
- 35