Adding the page content to a fluid template

浪子不回头ぞ 提交于 2020-01-01 07:30:15

问题


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?


回答1:


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.




回答2:


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>
}



回答3:


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).




回答4:


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



来源:https://stackoverflow.com/questions/15081508/adding-the-page-content-to-a-fluid-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!