[TYPO3-english] Accessing Object Data

Dmitry Dulepov dmitry at typo3.org
Fri Dec 12 22:14:46 CET 2008


Hi!

John Fox wrote:
> I¹m still learning Typo3 and must be thinking about this wrong.  I¹m
> thinking that the TEXT (video.10.conf.tx_dam.10) object is now populated
> with my keywords and that I should be able to access that data.  Any
> help/direction would be greatly appreciated.

It is not populated, that's the problem. TypoScript is not a programming language, it is a configuration language. So "video.10.conf.tx_dam.10" will always contain a string "COA", nothing else. If you want to have the value of the object identified by "video.10.conf.tx_dam.10", you need to force its ~processing~. The simplest way to do it is to use stdWrap. For example:

10 = CONTENT
10 {
	table = tt_news
	renderObj = TEXT
	renderObj.field = title
	select.andWhere {
		cObject < video.10.conf.tx_dam
		wrap = keywords LIKE '|'
	}
}

Here select.andWhere is of stdWrap type. It means that it will be processed to produce some value. This TS tells that cObject must be a copy of your TS object. cObject causes processing of your object when andWhere is processed but before andWhere produces the final result.

Next the result of the cObject processing is wrapped to create normal SQL statement ('wrap = ...').

The TS above is just for the idea. It is never good to use result of one query in another query (not safe from security point of view).

By the way, small optimnization hint for your code:

> video.10 = RECORDS 
> video.10.source = TEXT
> video.10.source.data = 9

More simple:

video.10.source = 9

> video.10.tables = tx_dam

You can get rid of the above if you use:

video.10.source = tx_dam_9

> video.10.conf.tx_dam = COA

Why the COA? You have only one object inside. You do not need a COA. It only increases processing time and eats memory. Just use:

video.10.conf.tx_dam = TEXT

and so on.

> video.10.conf.tx_dam {
>     10 = TEXT
>     10 {
>         field = keywords
>         wrap = |

There is no need for this wrap because it does not wrap anything.

So optimized TS is:

video.10 = RECORDS
video.10.source = tx_dam_9
video.10.conf.tx_dam = TEXT
video.10.conf.tx_dam.field = keywords

Smaller and more effective.

-- 
Dmitry Dulepov
TYPO3 core team
In the blog: http://typo3bloke.net/post-details/how_will_i_fix_bugs_in_extensions_from_now_on/
My TYPO3 book: http://www.packtpub.com/typo3-extension-development/book


More information about the TYPO3-english mailing list