[TYPO3-mvc] Find object properties, only using TypoScript
Albrecht Köhnlein
albrecht.koehnlein at gmx.de
Sat Oct 27 18:16:22 CEST 2012
I proudly present:
# FIND ARTICLE's PROPERTIES
# article is given as GP parameter
lib.tx_referencecontents_articleinfo = COA
lib.tx_referencecontents_articleinfo {
10 = CONTENT
10 {
table = tx_referencecontents_domain_model_article
select {
uidInList.data = GP:article
leftjoin = tx_referencecontents_domain_model_contactperson ON
(tx_referencecontents_domain_model_contactperson.uid =
tx_referencecontents_domain_model_article.contactperson)
}
renderObj = TEXT
renderObj {
field = headline
ifEmpty = ERROR_EMPTY_FIELD
}
}
20 = TEXT
20 {
value = ERROR_EMPTY_RESULT
if.isFalse.numRows {
table = tx_referencecontents_domain_model_article
select {
uidInList.data = GP:article
leftjoin = tx_referencecontents_domain_model_contactperson ON
(tx_referencecontents_domain_model_contactperson.uid =
tx_referencecontents_domain_model_article.contactperson)
}
}
}
}
/*
# example usage
anyMarker < lib.tx_referencecontents_articleinfo
anyMarker {
10.renderObj.field = email
10.renderObj.ifEmpty = fallback at example.com
20.value = fallback at example.com
}
*/
Am 27.10.12 17:25, schrieb Albrecht Köhnlein:
> Am 26.10.12 08:52, schrieb Christian Müller:
>>
>> On 25/10/12 20:19, Albrecht Köhnlein wrote:
>>> Hi list,
>>>
>>> I have created an extbase extension with multiple object models. One
>>> of the models is called Article, another one is called Contact. Each
>>> Article has a relation to one Contact, each Contact contains an email
>>> address as string property.
>>>
>>> On another page, in another extension, I would like to fill a marker
>>> with contents from my Article object and its related Contact object.
>>>
>>> # simplified typoscript:
>>> plugin.tx_myotherextension {
>>> anymarker = TEXT
>>> anymarker {
>>> #
>>> # What to do here to get Article's headline
>>> # or related Contact's email address?
>>> #
>>> }
>>> }
>>>
>> There is no such thing atm. Your best bet is to either use something
>> like CONTENT to fetch the entries or create a specialized plugin
>> (controller+action) to output the raw string with the needed data. But
>> if the other extension is yours too, why don't you get yourself the
>> repository from the first extension injected and go from there instead
>> of doing it in Typoscript?
>>
>> Christian
>>
>>
>
> Thanks for your reply. That's what I was afraid of.
>
> The other extension is not my own - and it even isn't an extbase extension.
>
> But I like your idea with the CONTENT element. I think I will
> create/prepare a TypoScript object in static TypoScript files of my
> extension, which I can use with 1 or 2 lines wherever I need to.
>
> Albrecht
More information about the TYPO3-project-typo3v4mvc
mailing list