如何让前端布局确定列和后端布局?

时间:2016-05-17 06:44:47

标签: typo3 typoscript fluid typo3-7.6.x

有没有办法让前端布局确定后端布局,模板文件和列?

目前,我有以下代码,允许您设置后端布局,并使用相应的模板文件。但是当每个布局有不同的列位置时,这会非常混乱。

page.10 = FLUIDTEMPLATE
page.10 {
    #format = html
    file= fileadmin/templates/example/partials/example_home.html    
    partialRootPath = fileadmin/templates/example/partials/
    layoutRootPath = fileadmin/templates/example/layouts/
    variables {

      # Assign the Columns
      main < styles.content.get
      main.select.where = colPos = 0

      news < styles.content.get
      news.select.where = colPos = 1
      }
    }
}


# Assign the Template files with the Fluid Backend-Template
page.10.file.stdWrap.cObject = CASE
page.10.file.stdWrap.cObject {
  key.data = levelfield:-1, backend_layout_next_level, slide
  key.override.field = backend_layout

  # Set the default Template
  default = TEXT
  default.value = fileadmin/templates/example/partials/example_home.html

  # Set a second Template
  23 = TEXT
  23.value = fileadmin/templates/example/partials/example_internal.html


}

1 个答案:

答案 0 :(得分:2)

根本不乱,这是一个真实世界的例子:

page.10 = FLUIDTEMPLATE
page.10 {
  file.stdWrap.cObject = CASE
  file.stdWrap.cObject {
    key.data = pagelayout

    default = TEXT
    default.value = {$customPagesTemplatePath}/Standard.html

    1 = TEXT
    1.value = {$customPagesTemplatePath}/Home.html

    2 = TEXT
    2.value = {$customPagesTemplatePath}/Landing.html

    10 = TEXT
    10.value = {$customPagesTemplatePath}/NewsDetail.html

    11 = TEXT
    11.value = {$customPagesTemplatePath}/LandingMini.html

    12 = TEXT
    12.value = {$customPagesTemplatePath}/FullWidth.html
  }
  layoutRootPath = {$customPagesLayoutPath}
  partialRootPath = {$customPagesPartialPath}

}

这样想:

  • 正如您所说,忘记前端布局。这是遗产;布局为BE和FE服务。

  • 如果某个页面是一个城市,则colPos将成为街道。或者更确切地说,想象后端是你正在绘制的地图,前端是你根据地图建立的乐高城市:-))如果没关系,我会坚持这个比喻。

ColPos是记录存在的页面的确定部分。如果可以,请查看数据库中的tt_content表:您将看到colPos只是一个带有数字的列。因此,在城市“第1页”中,有一条名为“colPos 7”的街道,它包含一些记录(那些将是房屋)。使用TYPO3中的be_layout向导,您将创建该城市的管理地图:编辑器应如何查看这些街道。

在您根据所选be_layout调用的FLUIDTEMPLATE中,您将创建城市本身;渲染的前端。

这是流体模板(Home.html)的另一个真实示例:

<f:render partial="Mobilenav" />
<f:render partial="Header"/>

<div class="row">
<f:cObject typoscriptObjectPath="lib.home-teaser" />
</div>

<aside>
  <div class="row">
    <div class="columns">
      <div class="row">
        <div class="fp-teaser-outer small-48 medium-24 large-12 columns">
          <div class="fp-teaser-box-wrapper">
            <f:cObject typoscriptObjectPath="lib.home-something" />
          </div>
        </div>
        <div class="fp-teaser-outer small-48 medium-24 large-12 columns">
          <div class="fp-teaser-box-wrapper">
            <f:cObject typoscriptObjectPath="lib.home-somethingelse" />
          </div>
        </div>
        <div class="fp-teaser-outer small-48 medium-24 large-12 columns">
          <div class="fp-teaser-box-wrapper">
            <div class="fp-teaser-box">
              <f:cObject typoscriptObjectPath="lib.home-news-plugin-title" />
              <div class="fp-teaser-hr"></div>
              <div class="fp-teaser-content">
                <f:cObject typoscriptObjectPath="lib.home-news" />
              </div>
            </div>
          </div>
        </div>
        <div class="fp-teaser-outer small-48 medium-24 large-12 columns">
          <div class="fp-teaser-box-wrapper">
            <div class="fp-teaser-box">
              <f:cObject typoscriptObjectPath="lib.home-blog-plugin-title" />
              <div class="fp-teaser-hr"></div>
              <div class="fp-teaser-content">
                <f:cObject typoscriptObjectPath="lib.home-blog" />
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</aside>

<f:render partial="Footer"/>

......好吧,但与colPos的相关性在哪里? 无处可去!我(虽然肯定有其他方法)在TypoScript中这样做:

lib.home-something < styles.content.get
lib.home-something {
  select.where = colPos = 7
}

因此,我们为流体模板准备内容:获取该页面第7列的所有内容(使用扩展名fluid_styled_content)并将其放入“lib”内容对象中。

然后通过f:cObject viewhelper:

将其插入到页面中
<f:cObject typoscriptObjectPath="lib.home-something" />

像这样,第7街的所有房屋都在这个位置放入城市 - 然后在你的页面中呈现。