0

I have an object defined in TypoScript

page.10 {
  variables {
    myObject = COA
    myObject{
     1 = TEXT
     1.value = yome Text
     2 = TEXT
     2.value = 42
    }
  }
}

and I need the data of the myObject in a partial

<f:render partial="myPartial" arguments="{content:myObject}" />

that looks like

<section id="myPartial">
<h2>{content.1}</h2>
<p>{content.2}</p>
</section>

Although the content is there ( because {content} will display all the properties) I cannot access it and h2 and p will be empty...

What should I do to fill h2 and p with the content of myObject?

3 Answers 3

0

That is not possible. TypoScript only returns text strings at the moment, not arrays. Thus the variable myObject contains the whole concatenated string of the COA, thus yome Text42.

Note that COA means Content Object Array, but the whole COA is one single object that is returned as one string.

2
  • I see. So I need to write a View Helper with an own Controller, right?
    – Chakaiko
    Jul 30, 2012 at 20:36
  • Or you need to split the data into multiple variables.
    – pgampe
    Aug 2, 2012 at 21:54
0

Alternative: use the VHS extension's v:var.typoscript ViewHelper:

{namespace v=Tx_Vhs_ViewHelpers}
{v:var.typoscript(path: 'page.10.variables.myObject') -> v:var.set(name: 'myObject')}

After which you can access {myObject.1} etc. in your template. Note that the so-called "chained" usage of v:var.set is optional, but will make it easier to access your variables using an intermediate template variable instead of more expensive calls to retrieve the value completely in multiple locations. The other way:

{v:var.typoscript(path: 'page.10.variables.myObject.1')}
{v:var.typoscript(path: 'page.10.variables.myObject.2')}
etc.

VHS extension on TER: http://typo3.org/extensions/repository/view/vhs

0

You can use FLUIDTEMPLATE.settings to provide custom data to the view. In your case:

page.10.settings {
  myObject {
    foo = bar
    bar = foo
  }
}

The partial call should look like this:

<f:render partial="myPartial" arguments="{content:settings.myObject}" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.