1. Home
  2. Blog
  3. Contact
Blogitems
15Mar

Pimp my Backend: TCAmanipulate

Posted on March 15th 2010 at 08:00 inside Extension DevelopmentExtensionsTypoScript with 9 comments

A while back we a colleague of mine discover this sweet extension in the TER, after experimenting with it a little we discovered that it was actually quite cool and very useful! Basically, it allows you to reset and rearrange any TCA settings with TypoScript through Page TSconfig.

So what could we use this for?

Let's make a hypothetical assumption, that we would like the extension tt_news for more things than just displaying news. It has a list, single and latest view, categories and lots of other useful stuff that you might want to use for something else as well. Of course our customer is going to be confused to see all the records as news records. This is where a little TCA manipulation can be useful. We can use the same database table for storage, have the same features on the front-end. However, our dear customer will not see that we are using tt_news in the back-end.

Sounds cool, so what do we need?

It's pretty basic to install, just download and upload/import the extension and install it. After that we are already ready to use it. Now I can start bragging on how to set it up, but of course it would be a lot easier and more clear to give a nice little example :-)

An example..

In this example, I would like to use tt_news for 2 things. The first will be standard, displaying news. So for this we are going to leave everything as it is. The next thing we want to achieve, is to use tt_news to store portfolio items. We could do something like this because we will have the same properties as tt_news. Single, list and latest view, and we would like to categorize them. The only difference between this and news will be the name and some of the fields. The portfolio items will for example only have the following details.

  • Name (title)
  • Website (links)
  • Category (category)
  • Short description (short)
  • Full description (bodytext
  • Date (datetime)

This should already not be a problem with normal Page TSconfig, but it's made even easier with TCAmanipulate. We can use the exact same structure as is found in tca.php files found in extensions. What are going to do first is change the table headers and record icons. We do this by entering the following code in the Page TSconfig.

Converting news articles to portfolio items 

  1. TCA.tt_news {
  2.   ctrl {
  3.     title = Portfolio items
  4.     iconfile = /fileadmin/images/icons/portfolio.gif
  5.   }
  6. }
  7. TCA.tt_news_cat {
  8.   ctrl {
  9.     title = Categories
  10.     iconfile = /fileadmin/images/icons/category.gif
  11.   }
  12. }
TCA.tt_news {
  ctrl {
    title = Portfolio items
    iconfile = /fileadmin/images/icons/portfolio.gif
  }
}
TCA.tt_news_cat {
  ctrl {
    title = Categories
    iconfile = /fileadmin/images/icons/category.gif
  }
}

This will transform our list view (only from this page) from this:

To this:

Now the next thing we want to do is disable and rearrange some fields. Now normally we could already disable fields with Page TSconfig, but we would have to disable each field seperately. With this cool tool we can simply just re-specify the fields that we want to have displayed :-) We will display only the fields mentioned above. And to make it even more fun, we will put a tab divider in it as well.

Redefining what fields should be displayed, and adding a divider (tab) 

  1. TCA.tt_news.types.0.showitem = datetime,title,short,bodytext,--div--;Relations,links,category
TCA.tt_news.types.0.showitem = datetime,title,short,bodytext,--div--;Relations,links,category

Next to the fact that we can easily say which fields should be displayed, we can also change their behavior and appearance with some small settings. Let's say we want to change the labels of these fields as well, and also make it only possible to select only 1 category. Let's just add some more TS to it :-)

Redefine what the fields should look like 

  1. TCA.tt_news.columns {
  2.   short.label = Short description
  3.   bodytext.label = Long description
  4.   category.config.size = 1
  5.   category.config.maxitems = 1
  6. }
TCA.tt_news.columns {
  short.label = Short description
  bodytext.label = Long description
  category.config.size = 1
  category.config.maxitems = 1
}

Now if we edit a "news" record we will get something like this:

Conclusion

This extension can prove extremely useful in some situations, and may prevent you from modifying extensions in order to get your back-end display to what you want. In my opinion this would be a nice thing to have in the TYPO3 core.

Tags

typo3 tcamanipulate tca pimp my backend

Comments (9)

Gravatar: BenjaminSBenjaminS2010-03-15 11:41

Who needs to make his own extension when some extensions with different names would rock the same way.!



I totally agree that this would be a good addition to the typo3core.

Gravatar: IdarIdar2011-01-31 18:15

Doesn't seems to work with tt_news 3.0 ?

Hi Sebastiaan,
I tried to manipulate the tt_news 3.0.1, but doesn't seems te work.
I managed to change the titles only.
I can't change the icons and hide some fields (author , author email etc etc)
 
Graag wat help aub?
 
Idar

Gravatar: IdarIdar2011-02-09 09:22

Doesn't seems to work with tt_news 3.0 ?

Can you give me some pointers in tt_news 3.0
In this newest version, the TCA manipulate, doesn't seems to work!
 
groetjes,
Idar
 

Gravatar: Sebastiaan de JongeSebastiaan de Jonge2011-02-09 10:24

RE: Doesn't seems to work with tt_news 3.0 ?

Hey Idar,
 
Sorry, your previous comment got stuck as being invisible :-)
 
Sure, but can you show me the code you've used (use pastebin or something for the snippet) and what you are trying to achieve?
 
Cheers,
Sebastiaan

Gravatar: ChrisChris2011-07-12 10:04

typeicons and typo3 4.4

I'm having problems changing the typeicons for tt_news 3.0.1 in typo3 4.4.*
 
TCA
...
}
}
 
Works fine in 4.3.* but not in 4.4.*
 
Any clue as to why?

Gravatar: Sebastiaan de JongeSebastiaan de Jonge2011-07-13 16:24

RE: typeicons and typo3 4.4

Hi Chris,
 
To be honest I haven't tried out TCA manipulate together with tt_news 3.x. However there are some deprecated function problems from I think 4.4 already with TCA manipulate. Have you modified the extension by any chance (there's a ereg_replace stuck in the code of the extension somewhere.
 
Cheers,
Sebastiaan

Gravatar: derSvenderSven2012-11-30 12:03

Modul-Menu Title

hi. i want to rename the "News" Title in the left Module-Menu.
in ExtTables i tried these conf - but how is the title for this position:
$GLOBALS[‘TCA’][‘tt_news’][‘ctrl’][‘title’] = ‘My Title’;

Gravatar: Sebastiaan de JongeSebastiaan de Jonge2012-12-19 16:47

RE: Modul-Menu Title

Hi Sven,
 
That would be:
TCA.tt_news.ctrl.title = Your new title
 
Simply follow the path in TCA itself.
 
Cheers,
Sebastiaan

Gravatar: Ivano LubertiIvano Luberti2013-02-26 10:15

tcamanipulate doesn't catch all TCA loadings

I used tcamanipulate 0.1.7 in TYPO3 4.5.16 to change how an extension displays one of its fields in the backend: in this case it was powermail 2.0.4.
It works properly when the whole form is loaded but not when an ajax request is called to collapse an inline field.
This is because in that case TCA is loaded in an execution flow where there is no hook for
 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['postUserLookUp'][]
 
To work around this I have implemented the same function of tcamanipulate that is called for the hook:
 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass']
 
so I can reload the modified TCA just before deciding what kind of field has to be shown.
I hava had also to tweak the function, because parameter passed by the ajax request are not enough for the old function to know the page id. I used the uid of the record is currently displayed to build the TSConfig and then to overwrite the TCA.
 
 
 

Your comment