Archive for the ‘Typo3’ Category

Altering behavior of existing extensions in Typo3 through the TCA

Monday, December 18th, 2006

I’ve learnt some really nice things the last days with Typo3. I got familiar with the TCA. The TCA [1] controls behavior and data for tables in Typo3. I needed to change the Country field in tt_address from being a boring string input field to become a dropdown selection field. I’m amazed over how simple this is to accomplish.

I got a custom extension mostly generated using the extension kickstarter [2]. That extension adds a lot of extra tables and record types for my client. Amongs these a list of countries and regions for each countries. I wanted to connect these countries to a tt_address record and by that replace the standard country string input field.

This is done easily by editing my ext_tables.php and add the following piece of code:

  1.  
  2. //
  3. // modify tt_address country field to be a dropdown..
  4. //
  5. $ttAddressModCols = Array (
  6.     "country" => Array (   
  7.       "exclude" => 1,  
  8.       "label" => "LLL:EXT:lang/locallang_general.xml:LGL.country"//we’ll borrow the original title for country fields 
  9.     "config" => Array (
  10.       "type" => "select"
  11.       "items" => Array (
  12.         Array("",0),
  13.       ),
  14.       "foreign_table" => "tx_mereaclientname_countries"
  15.       "foreign_table_where" => "ORDER BY tx_mereaclientname_countries.uid"
  16.       "size" => 1
  17.       "minitems" => 0,
  18.       "maxitems" => 1,
  19.     )
  20.   ),
  21. );
  22.  
  23. t3lib_div::loadTCA("tt_address");
  24. t3lib_extMgm::addTCAcolumns("tt_address",$ttAddressModCols,1);
  25.  

That’s it :)

What it does is; create a temporary array of settings for the tt_address table called ttAddressModCols and define a new definition of the country field for tt_address (replacing the current) with my database relation field. It uses the standard country label translation for consistancy. Finaly load tt_address’ TCA definition and merge it with our adaptation.

[update 2006-12-18]
Noteworthy when doing like above is that data is stored in the original database field. You might want to replace that field as well with your own type. For the above I would go with


alter table tt_address change country country INTEGER

in the sql script of my extension. Feels a bit wrong to use varchar to store integers… ;-)

REFERENCES:
[1]http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.0.0/view/4/1/
[2] http://typo3.org/extensions/repository/view/kickstarter/0.3.8/

Typo3, IIS, PHP 5 and MySQL 5 not funny at all..

Wednesday, November 22nd, 2006

In a project we are doing for a client we needed (naturaly) to setup a development server equal to th clients setup. This included:

* IIS 5
* MySQL 5.x
* PHP 5.2
* Typo3 4.0.2

..along with a bunch of extra stuff such as ImageMagick and so forth.
Having used Typo3 4.x with PHP 5 and MySQL 5 versions for some month without any major problems I thought this would go about the same. Shame on me. To beginning I had problems getting PHP to act valid together with the IIS. This was solved in a simple but clever way found at php.net by first installing php using the automated install script, and then replacing everything with the contents of the php-zip to get a better base.

MySQL was fortunately already installed on the dev server.

So, I moved forth with the Typo3 setup. After some fiddeling with trying to use GraphicsMagick instead of ImageMagick (which I gave up since I couldn’t find any info on how to wrap IM functions for GM under windows), I got a basic Typo3 setup done. But when I tried to add a default admin user, my problems continues. The setup tools reports a valid creation of the user, but nothing comes into my be_users table.. After som readings on the net I found this bug. It ended up in manually adding a BE user (exported it from another Typo3 installation). fixing the be_sessions.ses_data to allow null values made the user actually log in to the be as well! wow..

Anyway.. I’m on track again but I still can’t log in to the install tool as it only seems to reload back.. But hey.. most of those settings can be done manually in typo3conf/localconf.php so that’s not really a problem but still an irritating thing..

Editing Typo3 templates and constants localy

Thursday, September 28th, 2006

I found a great way of editing my typo3 templates. JEdit (the incredibly flexible java based code editor found at jedit.org) has a plugin for Typo3 which gives you direct access to constants and templates thruout the entire site structure.

Requirements/parts:
jEdit installed with Typo3 plugin
Typo3 version 3.8> (known to work up to 4.0.1)
xml support in PHP
Typo3 extensions: xmlrpc_lib and jeditvfs.

The following steps helps you set up the environment correctly:

1) Install xmlrpc_lib and jeditvfs to Typo3 with Typo3 extension manager.
It should work out of the box, but you can, if you like to, add some custom TS settings:

  1.  
  2. jeditpage = PAGE
  3. jeditpage.typeNum = 761
  4. jeditpage.config {
  5.         no_cache = 1
  6.         pageGenScript=EXT:jeditvfs/server.php
  7.         admPanel = 0
  8. }
  9.  

2) download and install jEdit from
jedit.org

3) Start jEdit and go to menu Plugins -> Plugin manager and then the install tab. Check TypoScript for Typo3 and install.

4) Now add a new Typo3 site. Close the Plugins manager and go to menu Plugins -> Plugin options. Select TypoScript and then the + button to add a new site.

5) Close the Plugin options window and go to menu Plugins -> TypoScript for Typo3 -> Template browser. Double click on your website name and voila – your in the game!