Adding the page content to a fluid template

2020-06-30 03:56发布

I'm new to TYPO3 and Fluid and trying to display the page content using a Fluid template similar to the following one:

<div id="content">
   <f:format.html>{content}</f:format.html>
</div>

The page data is entered via the backend using a two-column layout (colPos=0, colPos=1).

I am now trying to display the content of the first column (colPos=0) inside the div.
At the moment, my TYPO-Script looks like the following:

page = PAGE
page {
   # ...

   5 = FLUIDTEMPLATE
   5 {
        file = fileadmin/templates/default.html

        # ...

        variables {
           pageTitle = TEXT
           pageTitle.data = page:title    

           content = CONTENT
           content {
              table = tt_content
              select {
                 where=colPos=0
              }
              renderObj = COA
              renderObj {
                 10 = TEXT
                 10.field = bodytext
              }
           }
      }
}

It works this way, but I cannot get rid of the feeling that my 5.variables.content is way too complicated.

I saw some solutions using content < styles.content.get as an alternative but using this causes my resulting div to be empty.

Are there any more elegant ways (i.e. shorter in this context) to achieve what I am doing?

4条回答
forever°为你锁心
2楼-- · 2020-06-30 04:32

Alternative solution: https://fluidtypo3.org/viewhelpers/vhs/development/Content/RenderViewHelper.html (along with get and random get/render counterparts).

查看更多
3楼-- · 2020-06-30 04:35

On your question which approach is more elegant (I don't use fluid, but I think it's general Typoscript):

If you want to use css_styled_content, but with more flexibility and transparence than the shortcuts "get", "getLeft" etc., use this:

content < styles.content.get
content.select.where = colPos = 0

No need to specify content = CONTENT in that case.

In the way you wrote it above, you would probably need to add:

10.parseFunc = < lib.parseFunc_RTE

to your renderObj, as else, automatically linked e-Mail addresses etc. won't be rendered in the content.

If you want full control over the markup, your original approach using the CONTENT object is superior to css_styled_content. But you will have to cover each field the editors are supposed to use.

I always use this article: http://www.typo3wizard.com/en/articles/explaining-the-content-object.html

With css_styled_content on the other hand, you get parsing for all fields for free - but also you get all the markup it will write for you.

It might be helpful to look at csc's static template in /typo3/sysext/css_styled_content/static/setup.txt to see what it does.

查看更多
Summer. ? 凉城
4楼-- · 2020-06-30 04:52

page.5.variables.content < styles.content.get

Of course you must have the CSS styled content extension installed (default) and the static template "CSS Styled content" included in your TypoScript Template (Tab: Includes).

查看更多
男人必须洒脱
5楼-- · 2020-06-30 04:56

i dont use fluid, just plain TS for my projects, but i hope ill help.

In backend the cols are like this if u have not "touched" em:

| col1(Left) | col0(Normal) | col2(Right) | col3(Border) |

What i do is this for "normal" layout:

page.10 = TEMPLATE
page.10 {
  subparts{
    LEFT-CONTENT < styles.content.getLeft
    CONTENT < styles.content.get
    RIGHT-CONTENT < styles.content.getRight
  }
  marks {
    DESCRIPTION < styles.content.getBorder
  }

If u need something more u can use something like this to generate some content that is not on that page and can use it to display it on all pages.

subparts{
LEFT-CONTENT < styles.content.getLeft
LEFT-CONTENT {
  select.pidInList = 50
  select.where = colPos=0
  select.orderBy = sorting
  wrap = <div class="col100">|</div>
}
查看更多
登录 后发表回答