Monthly Archives: Juli 2007

Typo3 Using typoLink in your own FrontEnd (FE) extension

Using the the typoLink function in your own Typo3 extension is very simple. First you need an instance of the tslib_cObj object. Then setup the config array and call the method. That’s all.
To create the instance you need to include the object first:

include_once(PATH_site.'typo3/sysext/cms/tslib/class.tslib_content.php');

Then create the tslib_cObj:

$cObj=t3lib_div::makeInstance('tslib_cObj');

Setup the config array: (See the typoLink documentation of possible entries)

$conf = array( 'parameter' => 'http://www.bstar.de' );

Call the method:

echo $cObj->typoLink('bstar.de', $conf );


If you don’t want to setup the conf array and don’t need the power of typoLink you can use getTypoLink also:

echo $cObj->getTypoLink('bstar.de', 'http://www.bstar.de' );

Cron sends no mail to MAILTO address

When you are using cron to do some automatic jobs and want the output to be mailed, be sure you are entering the mail address in the right format. In this case it means that the mail address must not contain an „_“ (underscore)! If you enter into the MAILTO env of the crontab a mail address which contains an underscore you’ll wait forever 😉
Of course this behavior depends of your cron version …

So don’t use an underscore when ever you are able to do.

Typo3 locallang.xml and UTF-8 II

Again I need to talk about the default section of the locallang.xml. When you are following the tip of my last post you may encounter an other problem. You don’t have a default anymore (yeah! I know I suggest to remove the default section). This is may a problem if you need to handle many languages and don’t had translate all of them right now.
So here comes my bad work-around.

  1. open ../t3lib/class.t3lib_div.php in an editor
  2. search for:
    $LOCAL_LANG['default'][$labelKey] = $csConvObj->utf8_decode($labelValue,'iso-8859-1');
  3. replace 'iso-8859-1' with $origCharset
  4. save the file
  5. you may need to clear you llxml cache

Now you can use the default section again and UTF-8 characters are working fine.

Typo3 output UTF-8 in your own extensions

After you had finally master your the utf8 convert of you Typ3 installation may encounter an other problem. Your own extension is not producing utf8 output.
Your first idea will be to add "SET NAMES UTF8;" to you database connection when using the DBAL of Typo3. But this is not your problem 😉 $GLOBALS['TYPO3_DB']->exec_SELECTquery (which is actually using the DBAL) gives your right want you want!

After a while you’ll may find out that you’ve used for some reasons htmlentities. And this is your problem! But don’t panic. You just need to added some more parameters and the world will be fine again. Just add ‚UTF-8‘ as third parameter to give the function a hint that you are using uft8. Tricky … isn’t it 😉

So it will look similar like this:
$str = htmlentities( $dbData, ENT_COMPAT, 'UTF-8' );

Typo3 locallang.xml and UTF-8

Building a multi language site can be very hard. First of all you need be sure that you are running Typo3 and your database with the correct encoding. UTF-8 is your friend! Apply all the setting you need for you installation (have a look at http://wiki.typo3.org/index.php/UTF-8_support will may help you) and also ensure your database is using UTF-8. (BTW: If you database tables are using UFT-8 you do NOT need to set $TYPO3_CONF_VARS[‚SYS‘][‚multiplyDBfieldSize‘] and do not forget to run database->compare of the installation tool)

Now your Typo3 installation is working fine. Really? Have you checked your own extensions? Ups! There is may a problem if you use getLL and locallang.xml. Some chars are may mess up even if the locallang.xml looks fine (of course you are using an UTF-8 enabled editor and you are saving this file as UTF-8).

The problem is the „default“ languageKey setting. You are not allowed to use any encoding then ansi. But what if you need some special chars there? Be sure you set an other default key (for example „config.language = en“ will do this job for english) and rename „default“ to „en“. Now you are fine!