Search code examples
typo3typoscripttypo3-9.x

Typo3: Rendering content elements from another plugin


I've created a Page and added a template to this page in the backend view, I've added this setup to my template:

# Default PAGE object:
config.contentObjectExceptionHandler = 0
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
   templateName = System-Template
   templateRootPaths.10 = EXT:tjms/Resources/Private/Templates/Page/
   variables {
      contentNormal < styles.content.get
   }
}

Now as you can see the Template for this page is in my Plugin "tjms" (tjms/Resources/Private/Templates/Page/) in this System-Template.htmlI've added the following code:

<html
  data-namespace-typo3-fluid="true"
  xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
>
  <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '0'}" />
</html>

On my Page in the admin backend I put a Content Element on it, more specifically, I've added a Dynamic Content Element (https://extensions.typo3.org/extension/dce/) to the page. The problem I've now is that when I open the page I receive this error all the time:

No Content Object definition found at TypoScript object path "lib.dynamicContent"

Which I figured is probably because my plugin cannot access the lib.dynamicContent of the DCE Plugin? Is there a way to somehow link it? Or is my only option to put my System-Template inside the DCE Plugin?

Thanks for any help!


Solution

  • For the foremost error at hand you can take https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/ContentElement/Helper/DynamicContent.typoscript and include it in your TypoScript setup (@import ...). This is a quite powerful and well-known TypoScript-snippet which allows filtering for column and page and allows using column content inheritance (aka "slide") and convenient wrapping of content elements ('elementWrap'). I consider it the Swiss army knife of TYPO3 content rendering.

    But from there I think you have a misconception about page templates and content elements. Maybe I just did not understand what your motivation is.

    You have defined a variable "contentNormal" for your Fluid page template already. Probably it does not give you what you want (styles.content.get includes all the content and is not filtered for 1 column). Yet you can use it in Fluid {contentNormal -> f:format.raw()}.

    Your content element should have nothing to do with your page template but is something totally different. If you get this error only when you put this content element on the page that would mean that the content element tries to render lib.dynamicContent which would only make sense if you were doing some really special stuff like rendering a column from another page.