blog.Resource

Archive:

News-Feeds:


RSS 2.0
RSS 0.91
RDF
ATOM 0.3
May 6, 2011

Get more out of your boring TypoScript constants!

Category: Søren Malling

Many extensions requires you to select some sort of record. Mostly this is done, by finding the correct uid and then enter it into a field.. This can be done a lot more "beautiful"!

How you can make your extension constants more dynamic and useful

How you can make your extension constants more dynamic and useful

.. and you can use it inside your constant editor!

.. and you can use it inside your constant editor!

Even flexforms! This is sweet!

Even flexforms! This is sweet!

First of all, I can not take full credit for this post! A big ton of credit goes to Opens external link in new windowGeorg Ringer, he wrote a proof-of-concept extensions, showing how these functions can be used! And many other extensions uses the same functions, big credit to these developers as well, for spreading the usage of great usability!

This post is based on the code from Opens external link in new windowthe extension EXT:constantsextended. The picture to the right, show the extension manager right after you installed the extension. Pretty impressive and really good looking.

Just imagine your own extensions with these settings, where the field actually gives the user (your customer?) the possibility to choose a record - not write some "random integer".

Opens external link in new windowext_conf_template.txt (the file "creating" the extension manager configuration) shows you how this is made. It shows references to a PHP file, Opens external link in new windowfind it here, just next to all the other files in the extension :-)

But that's not a constant editor?

No, I'm very well aware of that, and the headline of this post does promise you something to spice up your constants - so here comes! :-)

Start by looking at the second picture - you got the same fields there aswell! The "secret" (well, not really a secret :P) is that ext_conf_template.txt and your included constants.txt file uses the same syntax, when it comes to rendering a form. Opens external link in new windowJust look at the constants.txt file.

For the technical interested person, it's parsed through the function Opens external link in new windowt3lib_tsparser_ext::printFields so if you are interested go through that code.

Why should i use it? Is anybody even doing this?

The two quick answers is

  1. Because it makes your extensions (meaning your work and "porfolio") look professionals
  2. Yes! Indeed!

Another (important!) reason for you to use such functions is: You are "insured" (you may not depend 100% on the data, still do your checks!) that you get the correct data and not a mistyped integer, when the user should actually select a usergroup!

And when it comes to the extension have a look at Opens external link in new windowEXT:templatevoila and the corresponding Opens external link in new windowuserfunction file.

And a another example would be Opens external link in new windowEXT:image_autoresize where a Opens external link in new windowflexform is integrated in to the extension configuration!

But i don't know how to do!! :'(

I didn't know how to walk, bike, swim, TYPO3 etc. either, before I tried and learned from my mistakes :-)

I really think that these great examples gives you a lot of code that you can base your own work on. And if you still got questions, Opens external link in new windowuse the maillists to get help. And remember to share your own experiences, so that others can learn from that!


comments

comment #1
Gravatar: Philipp Gampe Philipp Gampe May 7, 2011 18:05
Will this be part of core one day?

comment #2
Gravatar: Søren Malling Søren Malling May 7, 2011 22:28
What part? The userfunction possibility is (of course..) already a part of core. But concerning the dynamic fields, presented above, it's hard to predict.. Bring in a patch, and it might be :-)

comment #3
Gravatar: Stefan Galinski Stefan Galinski May 9, 2011 23:23
Just tried out the flexform configuration stuff in my latest extension df_tools (version not released yet). It needed some changes for my extension and CSH in TYPO3 4.5, but it works great. Big thanks for writing the article and to give an understanding of the basic ideas! :-)

comment #4
Gravatar: Gry Przegladarkowe Gry Przegladarkowe May 15, 2011 14:24
Brillsnt! Im begginer in typoscript and this feature helped me

comment #5
Gravatar: Beats by Dr Dre Beats by Dr Dre May 18, 2011 13:47
good cms,Big thanks for writing the article

comment #6
Gravatar: Frans Nogiet Frans Nogiet June 2, 2011 09:54
Nice post. Helped me alot

Sorry, comments are closed for this post.