Extension Development
From TYPO3Wiki
<< Back to Developer manuals page
You find all the different extension development manuals either by the extensions themself or in the TYPO3 documentation matrix.
[edit] Development Mini-HOWTO
This is a small HowTo showing you how to start developing for TYPO3.
[edit] External resources
- Use the PHP Manual.
- Download a PHP development environment
- Use a tool like fabFORCE DBDesigner4 to draw your database tables and the relationships among them.
[edit] Documentation
- Read the TYPO3 API Documentation.
- Install the <extension3>extdeveval</extension3>
or the newer (in development, requires fn_lib extension) <extension3>t3dev</extension3>. It gives you the APIs for extensions and a link list to documentation.
- Search in the Namazu: Full-Text Search Engine.
- Follow the Project Coding Guidelines
- Read the Extension Developers Guide (XDG)
- Extension Development, using Flexforms
- Backend Programming
- Translate and document your extension following the TYPO3.org - manual for developers (How typo3.org works)
- Use the Documentation template for yor extension documentation Documentation template
[edit] Get the source code
- You can get the latest source code of TYPO3 extensions from TYPO3 Extension Development Platform and TYPO3 itself from the TYPO3 Content Management Framework.
- You can browse the source code for extensions at http://typo3xdev.svn.sourceforge.net/viewvc/typo3xdev/ the TYPO3 Core at http://typo3.svn.sourceforge.net/viewvc/typo3/TYPO3core/ or both at http://svn.t3.digitaldistrict.de/cgi-bin/trac.cgi/browser .
- If you want to download everything in a ZIP file have a look at the most recent downloads for developers.
[edit] Classes and functions
- global $TSFE (or $GLOBALS["TSFE"]), the main front end class, can be found in 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. See parseFunc
if (is_array($this->conf["parseFunc."])) {
$markerArray["###PRODUCT_NOTE###"] =
$this->cObj->parseFunc($markerArray["###PRODUCT_NOTE###"],$this->conf["parseFunc."]);
}
[edit] Flexforms
- If you wish to use flexforms in your extension, follow the Using Flexforms guide.
[edit] 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.
[edit] Unix
- Use this command line to search for a pattern in many files under Linux
cd directory-of-sources
find . -name '*.php' -exec grep -ni 'your search string' {} \; -ls
- Or, "man grep" and see if your installed grep can do something like:
grep -rniH --include '*php' 'your search string' directory-of-sources
- Use the Linux cheat sheet for a short description of Linux commands
[edit] Database
- Database Abstraction Layer - DBAL
To activate the writing of error messages when one of your database accesses fails, open the file typo3/t3lib/class.t3lib_db.php and change the line
// Debug: var $debugOutput = FALSE; // Set "TRUE" if you want database errors outputted.
to
// Debug: var $debugOutput = TRUE;
To get detailed infos about the created SQL command you make an error_log entry into the function, e.g. SELECTquery.
The following change will write all the created database statements into the error_log file:
function debug($func) {
error_log ($this->debug_lastBuiltQuery, 0);
In the Install Tool 'All Configuration' set
[SYS][sqlDebug] = 1 // Boolean. If set, then database queries that fails are outputted in browser. For development.
Or in typo3conf/localconf.php or somewhere in the code of your extension:
$TYPO3_CONF_VARS['SYS']['sqlDebug'] = 1;
[edit] Variables
- access the global variables, e.g.
global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
[edit] Use libraries and APIs
please add the ones you like. --Daniel Brüßler 11:03, 4 June 2007 (CEST)
- <extension3>meta_feedit</extension3>
- <extension3>rlmp_dateselectlib</extension3>
date selector, calendar javascript - <extension3>rgfolderselector</extension3>
folder selector field for the backend - <extension3>div</extension3>
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.
[edit] Caching issues
- read how to manage the cache - Caching and The Mysteries Of &cHash
- How to avoid the no_cache parameter? Proper Caching
- 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
[edit] Blocking errors
- If due to your coding TYPO3 stops working, just view the entries of the log file. (Linux: /var/log/messages or /var/log/httpd/error_log) and search for the string 'PHP Fatal error'.
[edit] HTML output into a file
To debug errors it would be usefull to let TYPO3 save the HTML output also into a file. Modify the printContent output function to save each page into the file typo3.log.
typo3/alt_main.php:
/**
* Outputting 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);
}
[edit] 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 namings. So the setup for one extensions could be used 1:1 for another extension as well.
