Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Extension Development

From TYPO3Wiki
Jump to: navigation, search

<< Back to Developer manuals page

[edit]

Warning: This page may contain totally outdated information!

You find all the different extension development manuals either by the extensions themself or in the TYPO3 documentation matrix.

A good place to start is the Extension Developers Guide (XDG)

Extension development mini how-to

This is a small how-to showing you how to start developing for TYPO3.


Development environments

Database development

Documentation

ExtDevEvalLinks.png

or the newer (in development, requires fn_lib extension) t3dev. It gives you the APIs for extensions and a link list to documentation.

External resources

The source code

Classes and functions

  • $GLOBALS['TSFE'], the main TypoScript front end class, can be found in typo3/sysext/cms/tslib/tslib/class.tslib_fe.php
  • Use parseFunc() to convert text from input to disallow HTML tags or allow only those the from the allowTags setting.
PHP script:
 if (is_array($this->conf['parseFunc.'])) {
    $markerArray['###PRODUCT_NOTE###'] = $this->cObj->parseFunc($markerArray['###PRODUCT_NOTE###'], $this->conf['parseFunc.']); 
 }

Flexforms

  • If you wish to use Flexforms in your extension, follow the Using Flexforms guide.

Multiple Languages

  • Create XML language files to support multiple languages. Use the locallang-XML translation tool to convert php language files into XML and do some cleanings.
  • Create overlay tables which contain only the fields which need translations. Use the Table Library to create SQL queries which hides the language overlay tables to the developer.

UNIX

  • Use this command line to search for a pattern in many files under *nix
shell script:
 cd directory-of-sources
 find . -name '*.php' -exec grep -ni 'your search string' {} \; -ls
It is more trickier if you want to search for $GLOBALS['TSFE'] in all PHP files:
shell script:
 find . -name '*.php'  -exec  grep "\$GLOBALS\['TSFE'\]"  {}  \; -ls
  • Or, man grep and see if your installed grep can do something like:
shell script:
 grep -rniH --include '*php' 'your search string' directory-of-sources
  • The Linux cheat sheet lists some commands for frequent tasks under Linux (most of these should also work under other flavors of Unix)

Database

To access the database, use the Database Abstraction Layer. DBAL

To enable database access debug output, open typo3/t3lib/class.t3lib_db.php and change the line:

PHP script:
 var $debugOutput = false;

to

PHP script:
 var $debugOutput = true;
To see detailed information about the created SQL, you can drop error_log() calls into the function, e.g. SELECTquery(). The following change will write all generated database statements into the error_log file:
PHP script:
 function debug($func) {
    error_log($this->debug_lastBuiltQuery, 0);
 }

You can also configure TYPO3 to output failed database queries to the browser.

  • Either by using the Install Tool: In the section 'All Configuration', set [SYS][sqlDebug] = 1
  • Or in typo3conf/LocalConfiguration.php or somewhere in the code of your own extensions: $TYPO3_CONF_VARS['SYS']['sqlDebug'] = 1;

Global variables

Important global variables are:

  • BE_USER
  • LANG
  • BACK_PATH
  • TYPO3_CONF_VARS
  • TSFE

</php>

Use libraries and APIs

please add the ones you like. --Daniel Brüßler 11:03, 4 June 2007 (CEST)

  • meta_feedit
  • rlmp_dateselectlib
    date selector, calendar javascript
  • rgfolderselector
    folder selector field for the backend
  • div
    Static methods for extensions. It has copies of itself as div<year> for each year in order to allow many versions of it at a time.

Caching issues

  • Generally you have to use the extension variable like 'tx_myext_pi_name[variable]'.
  • You can also define standalone parameters e.g. for 'begin_at', 'offset' and similars for which the cHash parameter will get created using these functions:
    • tslib_pibase::pi_getPageLink()
    • t3lib_div::cHashParams()
    • tslib_fe::makeCacheHash()

Blocking errors

  • If TYPO3 stops working due to your coding, just view the entries of the log file. (*nix: /var/log/messages, /var/log/httpd/error_log, ...) and search for the string 'PHP Fatal error'.

HTML output into a file

To debug errors, it would be useful if TYPO3 also saves the HTML output into a file. Modify the printContent output function to save each page into the file typo3.log.

PHP script:
# typo3/alt_main.php:
 /**
 * Outputs the accumulated content to screen and into a file
 *
 * @return	void
 */
 function printContent() {
  echo $this->content;
  $handle = fopen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT').'/typo3conf/','wb');
  fwrite ($handle, $this->content);
  fclose($handle);
 }

Standards

Take care of standards to make all TYPO3 extensions look very similar. This helps that others can easier understand your extensions and find the files in it. Standardization. These are the current recommendations. And you are invited to make your own proposals. All things which are needed in several extensions should be defined by the same names. So the setup for one extensions could be used 1:1 for another extension as well.

Send patches

Help