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.
Browser Tutorial User Defined Functions (en)¶
Author: | Kasper Skårhøj |
---|---|
Created: | 2002-11-01T00:32:00 |
Changed by: | Dirk Wildt |
Changed: | 2013-12-29T01:43:42 |
Classification: | browser_tut_userfunc_en |
Description: | The Browser provides some user defined functions (userFunc). The tutorial is a overwiew with the reference |
Keywords: | forDevelopers, forIntegrators, browser, userfunc, tutorial, typo3 without php |
Author: | Dirk Wildt, Die Netzmacher |
Email: | http://wildt.at.die-netzmacher.de |
Website: | http://die-netzmacher.de |
Language: | en |
extKey: browser_tut_userfunc_en
Browser Tutorial User Defined Functions (en)¶
The Browser provides some user defined functions (userFunc). The tutorial is a overwiew with the reference
Version: 4.8.5, 2013-12-29 - Version is corresponding with the version of the Browser.
Extension Key: browser_tut_userfunc_en - Tutorial for the extension Browser (extkey: browser)
Language: en
Keywords: forDevelopers, forIntegrators, browser, userfunc, tutorial, typo3 without php
Copyright 2009-2013, Dirk Wildt, Die Netzmacher, <http://wildt.at.die- netzmacher.de>
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¶
Browser Tutorial User Defined Functions (en) 1
What do the Browser userFuncs do? 3
User defined functions (userFunc) 4
Introduction¶
What does the Tutorial do?¶
This is a tutorial for the extension Browser (extkey: browser).
It is only
a step-by-step introduction for the Browser user defined functions (userFunc)
If you are interested in other issues, please note the section "Further Informations" below.
What do the Browser userFuncs do?¶
The Browser uses a lot of TYPO3 API functionality. This has two big benefits:
- The Browser developer save a lot of costs, they don't need to program code twice.
- You can configure TypoScript by the common way.
But sometimes the Browser needs more ore different functionality. The Browser user defined functions extend the Browser with this functionality.
The principle is the same: The developer tries to use the origin TYPO3-API code. This saves a lot of work and the configuration of a user defined function is near by the common way.
Further Information¶
This tutorial in PDF format¶
You find this manual as PDF file at
Browser Manual and Browser Tutorial Basics¶
Manual: The Browser has it's own manual (with the reference of course).
- HTML http://typo3.org/extension-manuals/browser/current/
- PDF http://typo3-browser.de/typo3conf/ext/browser/doc/manual.pdf
Tutorial Basics: A lot of step-by-step introductions.
User defined functions (userFunc)¶
numberformat¶
Deprecated!¶
The function is deprecated! Since TYPO3 4.5 the TypoScript is extended with a stdWrap property for formatting number formats.
If there is any reason, to use the numberformat method of the Browser, you may be use this method like in the snippet below.
Profile¶
You can configure
- the amounts of digits behind the decimal point
- the format of the decimal point (i.e. comma or dot)
- the format of the thousands seperator (i.e. comma or dot)
Example¶
12345 can become 12,345.00
TypoScript snippet¶
price = COA
price {
wrap = | {$quick_shop.currencySymbol}
10 = USER
10.userFunc = tx_browser_typoscript->numberFormat
10.userFunc {
number = TEXT
number {
value = ###TX_QUICKSHOP_PRODUCTS.PRICE###
}
decimal = 2
dec_point = {$quick_shop.dec_point}
thousands_sep = {$quick_shop.thousands_sep}
}
}
render_table¶
tt_content.table.20¶
You are using the TypoScript array tt_content.table.20 for rendering tables usually.
This TypoScript contains the userFunc
tx_cssstyledcontent_pi1->render_table
But this userFunc islimited:
for records from tt_content only
Profile¶
The render_tables method of the browser extends the render_tables method of CSS Styled Content with the capabilities:
to handle records of every table
It extends the userFunc property in particular.
TypoScript snippet¶
// datasheet
20 < tt_content.table.20
20 {
userFunc = tx_browser_cssstyledcontent->render_table
userFunc {
// add the value of a field to another field in cObj->data
cObjDataFieldWrapper =
cObjDataFieldWrapper {
cols = tx_quickshop_products.cols
pi_flexform = tx_quickshop_products.pi_flexform
uid = tx_quickshop_products.uid
}
}
field = tx_quickshop_products.datasheet
stdWrap {
// With a prefix comment there won't be any output!
prefixComment >
}
}
Example by Quick Shop¶
Quick Shop is using a table in the backend for displaying a datasheet in the frontend. See
http://typo3.org/extensions/repository/view/quick_shop/
Investigate Quick Shop¶
- See TCA at http://forge.typo3.org/projects/extension- qshop/repository/entry/trunk/tca.php Look for "datasheet"
- See TypoScript at http://forge.typo3.org/projects/extension- qshop/repository/entry/trunk/static/setup.txt Look for "render_table"
render_uploads¶
tt_content.uploads.20¶
You are using the TypoScript array tt_content.uploads.20 for rendering uploads usually.
This TypoScript contains the userFunc
tx_cssstyledcontent_pi1->render_uploads
But this userFunc islimited:
- for records from tt_content only
- for building filelinks for the current language only.
Profile¶
The render_uploads method of the browser extends the render_uploads method of CSS Styled Content with the capabilities:
- to handle records of every table and
- to building filelinks for files in all translations.
It extends the userFunc property and the linkProc property in particular.
You are able to build your own URL.
Markers¶
The extended method will replace the defined markers in most of the TypoScript code:
- ###KEY###You can upload more than one file. Every file has a key. The first one has the key 0, the second 1, the third 2 and so on. The key is the key of the current file.
- ###FILENAME###You can upload more than one file. Every file has a name. The name is the name of the current file.
- ###SYS_LANGUAGE.FLAG###The label of the flag of the current language. I.e. de, fr, gb, ...If the label is empty or the label is 'en', this marker will return 'gb'.Values are taken from the table 'sys_language'.
- ###SYS_LANGUAGE.TITLE###The label of the current language. I.e. English, Deutsch, Italiano.Values are taken from the table 'sys_language'.
- ###TT_CONTENT.UID###The uid of the current Browser plugin.
###KEY### AND ###TT_CONTENT.UID### are needed in context with rendering links.
TypoScript snippet¶
10 < tt_content.uploads.20
10 {
userFunc = tx_browser_cssstyledcontent->render_uploads
userFunc {
drs = TEXT
drs {
value = 0
}
}
filePath >
linkProc {
tx_browser_pi1 = TEXT
tx_browser_pi1 {
typolink {
parameter = {$plugin.org.pages.doc}
additionalParams = &tx_browser_pi1[docUid]=###TX_ORG_DOC.UID###&t x_browser_pi1[download]=###FILENAME###
useCacheHash = 1
returnLast = url
}
}
}
tableField = tx_org_doc.documents
fields {
from_path = ###TX_ORG_DOC.DOCUMENTS_FROM_PATH###
files = ###TX_ORG_DOC.DOCUMENTS###
files {
override = ###TX_ORG_DOC.THUMBNAIL###
}
layout = 2
}
stdWrap {
if.isTrue = ###TX_ORG_DOC.THUMBNAIL######TX_ORG_DOC.DOCUMENTS#### ##TX_ORG_DOC.DOCUMENTS_FROM_PATH###
}
}
DRS - Development Reporting System¶
If there will be any unexpected result, you can enable the DRS - the Development Reporting System and inspect the logs.
But because this is a user function, you don't have the full power of the Browser core code.
You have to enable the DRS by TypoScript but not by the extension manager.
You need the extension devlog.
You enable the DRS with a code like below:
userFunc.drs.value = 1
See the TypoScript snippet below.
TypoScript snippet¶
10 < tt_content.uploads.20
10 {
userFunc = tx_browser_cssstyledcontent->render_uploads
userFunc {
drs = TEXT
drs {
value = 1
}
}
...
}
Reference¶
plugin.tx_browser_pi1¶
This tutorial provides only the reference for the user defined functions (see below).
You find all other stuff in the manual of the Browser:
tt_content.uploads.20¶
See the common – the non extended – reference for rendering uploads in your TypoScript at
tt_content.uploads.20
Please take the TypoScript Object Browser for inspecting it.
tt_content.uploads.20 – extended¶
If you like to use the render upload method of the Browser, you have to allocate the user function like in the TypoScript snippet below:
10 < tt_content.uploads.20
10 {
userFunc = tx_browser_cssstyledcontent->render_uploads
...
}
linkProc.tx_browser_pi1¶
Property
linkProc.tx_browser_pi1
Data type
COA
Description
The property linkProc is an origin property of tt_content.uploads.20.
The Browser userFunc extends it with the a property and a register.
- tx_browser_pi1 is a content object (TEXT, IMAGE, COA, …).You can use it, to build your own URL for linking. If you are using the property tx_browser_pi1 it takes precedence over all other link parameters of linkProc.
- ICON_REL_PATH_FROM_LINCPROC will allocated with the path to the image source, which was rendered by linkProc while runtime. ICON_REL_PATH_FROM_LINCPROC is accessible for the property tx_browser_pi1 only!
Example:
linkProc {
tx_browser_pi1 = COA
tx_browser_pi1 {
// Link with preview or application icon
10 = IMAGE
10 {
file {
import {
data = register : ICON_REL_PATH_FROM_LINCPROC
}
}
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink {
parameter = {$plugin.org.pages.downloads},\
{$plugin.tx_browser_pi1.typeNum.downloadPageObj}
additionalParams = &tx_browser_pi1[plugin]=\
###TT_CONTENT.UID###\
&tx_browser_pi1[file]=\
single.301.tx_org_downloads.\
###TX_ORG_DOWNLOADS.UID###.\
documents.###KEY###
useCacheHash = 1
title = TEXT
title {
value = Download: '###TX_ORG_DOWNLOADS.TITLE###'
lang {
de = Herunterladen: '###TX_ORG_DOWNLOADS.TITLE###'
en = Download: '###TX_ORG_DOWNLOADS.TITLE###'
}
}
}
}
}
// Link devider
20 = TEXT
20 {
value = //**//
}
// Link with label
30 = TEXT
30 {
data = register : filename
typolink {
parameter = {$plugin.org.pages.downloads},\
{$plugin.tx_browser_pi1.typeNum.downloadPageObj}
additionalParams = &tx_browser_pi1[plugin]=\
###TT_CONTENT.UID###\
&tx_browser_pi1[file]=\
single.301.tx_org_downloads.\
###TX_ORG_DOWNLOADS.UID###.\
documents.###KEY###
useCacheHash = 1
title = TEXT
title {
value = Download: '###TX_ORG_DOWNLOADS.TITLE###'
lang {
de = Herunterladen: '###TX_ORG_DOWNLOADS.TITLE###'
en = Download: '###TX_ORG_DOWNLOADS.TITLE###'
}
}
}
}
}
tableField¶
Property
tableField
Data type
string
Description
tableField must have the syntax: table, dot and field. Example tx_org_doc.documents.
The tableField ist the table and the field, where you are storing your files.
Example:
tableField = tx_org_doc.documents
fields¶
Property
fields
Data type
array
Description
fields is an array with the elements:
- from_path
- files
- layout
Every element has the stdWrap property.
from_path: If you like to use a directory as a source.
files: The list of the uploaded files
layout: the document layout.
Example:
fields {
from_path = ###TX_ORG_DOC.DOCUMENTS_FROM_PATH###
files = ###TX_ORG_DOC.DOCUMENTS###
files {
override = ###TX_ORG_DOC.THUMBNAIL###
}
layout = ###TX_ORG_DOC.DOCUMENTSLAYOUT###
}
userFunc¶
Property
userFunc
Data type
array
Description
...
Forum¶
Illustration 1: The TYPO3-Frontend-Engine Browser Forum
The Browser has its own forum. We speak English and German. You are welcome to post any question, bug or snippet code at
TYPO3-Frontend-Engine Browser: Forum http://typo3-browser-forum.de/
To-Do List¶
Nothing to do.