简体   繁体   中英

Can I access the header of a text content element?

I need to get the headline and the text separately out of a text content element. The reason is, to give the editor a simple way to add a content for a complicated section in my html theme.

I am new to TYPO3 an we run V11.5.16. I read and watched some tutorials and I got most of my site already working! Contents are dynamic and multilinguale so far.

To get contents from backend, I use Backend Layouts and copy the content from styles.content.get inside my setup.typoscript. I think this is the common way to do it, and as I said, it works. I output them using {contentXY->f:transform.html()} or {contentXY->f:format.raw()} .

For a text content element, I get something like:

<div id="c270" class="frame frame-default frame-type-text frame-layout-0">
  <header>
    <h2 class="">Headline</h2>
  </header>
  <p>Some Text</p>
</div>

Is it possible to get only "Headline"? And if so, it hopefully works also for getting out separately "Some Text"

Something like: {contentXY->f:transform.html(filterBy('h2'))}

Thanks in Advance!

EDIT:

According to Peter Krause's answer: I know, there is an extra content element for headers. But I need the text content element, because for the places in the html, I need header AND text. And the editors are technically not savy enough to fill in different content elements. Please don't ask in more detail. ):

You can handle header and body of an CE seperately, but not in a page context.
In page context you get the result from rendering the CEs, which is a string (with HTML).

For each CE there is a rendering information, which nowadays is also FLUID.
Depending on your installation it probably is FSC (ext:fluid_styled_content) or a Bootstrap extension.
This means: there are FLUID templates which can be overriden and modified.
In these templates you have access to each field of a CE separately.

Look for the templates stored in the defined paths (in TSOB) and add your own path for overides:

lib.contentElement {
   templateRootPaths {
      1 = ...
      2 = ...
      3 = ...your path...
   }
   partialRootPaths {
      1 = ...
      2 = ...
      3 = ...your path...
   }
   layoutRootPaths {
      1 = ...
      2 = ...
      3 = ...your path...
   }
}

Thanks for all hints, I think, for my requirement. there is no solution out of the box. So i made a custom CE with Mask and edited the template html, For non-technical editors. it is the best solution in terms of data input. I hope this stands for future upgrades...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM