Extension Development

From TYPO3Wiki

Jump to: navigation, search

<< Back to Developer manuals page

[edit]

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

Contents

[edit] Development Mini-HOWTO

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

[edit] External resources

[edit] Documentation

Image:ExtDevEvalLinks.png

or the newer t3dev. It gives you the APIs for extensions and a link list to documentation.

[edit] Get the source code

[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

[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)

  • 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.

[edit] 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

[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.

[edit] Send patches

[edit] Help

Personal tools