简体   繁体   English

TYPO3:如何将页面内容插入模板

[英]TYPO3: How do I insert page content into template

I have some content that I want to appear on multiple pages of my TYPO3 site. 我有一些内容要在TYPO3网站的多个页面上显示。 I could just insert this into the template, but I also want that content to be editable in the Rich Text Editor. 我可以将其插入到模板中,但我也希望在Rich Text Editor中可以编辑该内容。

So I had the idea of creating a hidden page, but I don't know how to insert this content into a template. 所以我有了创建隐藏页面的想法,但我不知道如何将这些内容插入到模板中。

Does it require the select typoscript statement? 它需要select typoscript声明吗?

Also, as a follow-up question, can I add something to say, only include pages that have this page id as their immediate parent in the page hierarchy. 此外,作为后续问题,我可以添加一些内容,仅包含将此页面ID作为页面层次结构中的直接父级的页面。

I didn't quite get the second question. 我没有得到第二个问题。 If you want to include some record only to pages under some other page, then this will obviously work: 如果您只想将某些记录包含在其他页面下的页面中,那么这显然会起作用:

[PIDinRootline = pages-uid, pages-uid, ...]
temp.foo = RECORDS
temp.foo {
    tables = tt_content
    source = ID # Enter the object's ID here
}
[end]

On the other hand, if you want to include all records from pages, being children of some other page, then try something like: 另一方面,如果您想要包含页面中的所有记录,作为其他页面的子项,请尝试以下操作:

1 = CONTENT
  1.table = tt_content
  1.select {
    pidInList = parent-uid
  }

Don't know if I got you right though. 不知道我是不是你说得对。 Dmitri. 德米特里。

From Include typo3 content elements on every page : 每页上包含typo3内容元素

temp.foo = RECORDS
temp.foo {
    tables = tt_content
    source = ID # Enter the object's ID here
}

Note the ID is the content record ID, not the page ID. 请注意,ID是内容记录ID,而不是页面ID。

But that doesn't answer the question of how to only include pages/records with a certain parent. 但这并没有回答如何仅包含某个父母的页面/记录的问题。

You can set up a hidden page and then "import" the content elements on a given page via typoscript on the pages (or the entire page tree below) as needed. 您可以设置隐藏页面,然后根据需要通过页面上的typoscript(或下面的整个页面树)“导入”给定页面上的内容元素。 The "trick" is to use the colPos with the select-statement. “技巧”是将colPos与select语句一起使用。 With this you can even put multiple (different) content elements in one (hidden) page that show up on different pages (depending on the setting of the column they are "in". 有了这个,您甚至可以将多个(不同的)内容元素放在一个(隐藏)页面中,这些页面显示在不同的页面上(取决于它们所在的列的设置)。

Example: 例:

  • Create a hidden (or system) page (here example-pageid = $PID_STATIC) 创建隐藏(或系统)页面(此处为example-pageid = $ PID_STATIC)
  • Create a content element on this page (text) 在此页面上创建内容元素(文本)
  • Edit this content element to be shown on the right column (right equals colPos=2) 编辑此内容元素以显示在右列(右侧等于colPos = 2)
  • Put the following typoscript into the template on which you want the content element to be shown. 将以下拼写错误放入您希望显示内容元素的模板中。 You can set the pid (pageId) in the constants via PID_STATIC or "hardcode" it into the typoscript. 您可以通过PID_STATIC在常量中设置pid(pageId)或将其“硬编码”到typoscript中。

.

lib.aditionalcontent = COA
lib.aditionalcontent { 
   10 = CONTENT
    10 {
        table = tt_content
        select.where = colPos = 2
        select.orderBy = sorting
        select.pidInList = {$PID_STATIC}
    }
  • Add the element lib.aditionalcontent into your template where the content should be shown. 将元素lib.aditionalcontent添加到模板中,其中应显示内容。 For example: 例如:

.

page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/maintemplate.htm
page.10.workOnSubpart = DOCUMENT_BODY
page.10.marks.ADITIONAL_CONTENT < lib.aditionalcontent

.

Watch out, that you set the colPos according to the column that you have set the content element into, otherwise it just will not show. 注意,您根据已设置内容元素的列设置colPos,否则它将不会显示。

You can use different columns to do this for different content that has to show up/should not show up on a particular page. 对于必须显示/不应显示在特定页面上的不同内容,您可以使用不同的列来执行此操作。

This also works with sytemfolders and non-hidden pages. 这也适用于sytemfolders和非隐藏页面。

If you use TemplaVoila, this should also work although you have to switch to the listview to see and set the colum for the content element (if not hidden for this non-admin user). 如果你使用TemplaVoila,这也应该有效,尽管你必须切换到列表视图来查看和设置内容元素的列(如果没有为这个非管理员用户隐藏)。

To find out which colPos-number is which position of the column go to the phpMyAdmin and search for the field "colPos" in the tt_content table. 要找出哪个colPos-number是列的哪个位置转到phpMyAdmin并在tt_content表中搜索字段“colPos”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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