Category Archives: Typo3

Typo3 on Strato webhoster

If you ever need to install a Typo3 4.3 or higher on a Strato you may encounter a problem with ImageMagick. First of all you need an package which supports ImageMagick! If you package supports it then you may have the problem that ImageMagick Version 4.2.9 will not work and gives you that error: “There was no result from the ImageMagick operation“.

To solve this go to the All Configuration section of your Typo3 4.3 or higher installation. Search for [im_stripProfileCommand] and set it to blank.

That’s it!

Typo3 How to render RTE content of an extension

When writing your own Typo3 extension you may come to the day where you need to enter some free HTML content. This content may also include some links. No Problem so far. But if you save the stuff to the db Typo3 transforms the text. For example all a-Tags are written as <link XX>Test</link> and so on.
So when you like to render the text you need to revert the transformation. (At this point it doesn’t matter if you are using FlexForms or the traditional TCA configuration).
All you need to do is to call this method and everything goes fine:
[sourcecode lang=”php”]$outputText=$this->pi_RTEcssText($dbtext);[/sourcecode]

Typo3 Localize your own extensions

When you try to write your own front end (FE) extensions with Typo3 there are common pitfalls. First of all be sure you enabled your table to hold the information. (Can be done very easy via the kickstarter). Next be sure you don’t query do much information of your table. All you need are the row where “sys_language_uid=0″. Your translation is made via the getRecordOverlay ! This short code snippet may help you to resolve your problems:

[sourcecode lang=”php”]
function readDBData( $table, $where )
{
$back = array();

if ( $where!=”” )
$where.= ” AND “;
$where .= ” deleted=0 AND hidden = 0 AND sys_language_uid=0″;

$res = $GLOBALS[‘TYPO3_DB’]->exec_SELECTquery( ‘*’, $table, $where );
while ($row = $GLOBALS[‘TYPO3_DB’]->sql_fetch_assoc($res))
{
if ($GLOBALS[‘TSFE’]->sys_language_content)
{
$OLmode = ($this->sys_language_mode == ‘strict’?’hideNonTranslated’:”);
$row = $GLOBALS[‘TSFE’]->sys_page->getRecordOverlay( $table, $row, $GLOBALS[‘TSFE’]->sys_language_content, $OLmode);
}
$back[] = $row;
}

return $back;
}
[/sourcecode]

PS: Keep in mind this tip, too: Web List: ‘Localize-to-feature’

Typo3 RealURL and 404 file not found

When using RealURL in multi language environment sending an real 404 is sometimes not so easy. Some I just want to give you some hints:

First of all enable the pageNotFound_handling of Typo3.

  • open the file typo3conf/localconf.php
  • add these lines

    $TYPO3_CONF_VARS["FE"]["pageNotFound_handling"] = 'http://www.my-domain.com/en/not-found.html';
    $TYPO3_CONF_VARS["FE"]["pageNotFound_handling_statheader"] = 'HTTP/1.1 404 Not Found';

Now you need to check your RealURL config:

  • Be sure you that you have not set postVarSet_failureMode OR set it to postVarSet_failureMode=''
  • Also be sure you have defined 'noMatch'=>'bypass' for every single preVars section!

That’s all 🙂 Now you get the your wonderful 404 file not found page every time when a wrong page is hit.

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' );

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!