我已经构建了一个lib来将页面的所有子页面作为teasers。这到目前为止工作。在这个预告片中,我想要推出子页面的sys类别。为此,我使用(并修改)了我在这里找到的一个typoscript:Show category names of current page in TYPO3 8
但这不起作用 - 任何人都可以给我一个暗示吗?
这是我的代码:
lib.newsteaser {
20 = CONTENT
20 {
table = tt_content
select {
# Seiten-ID des Parent
pidInList = 17
recursive = 1
orderBy = tx_mask_cnt_news_item_date
where = hidden=0 AND CType='mask_cnt_news_item'
limit = 4
}
wrap = <section><div class="container-fluid"><div class="row no-gutters news-teaserbox">|</div></div></section>
renderObj = COA
renderObj {
wrap = |</div>
10 = FILES
10 {
if.isTrue.field = tx_mask_cnt_news_item_teaser_bg
references {
table = tt_content
# Seiten-ID
uid.dataWrap = {field:uid}
fieldName = tx_mask_cnt_news_item_teaser_bg
}
renderObj = TEXT
renderObj.data = file:current:publicUrl
renderObj.wrap = <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12 news-tb-item" style="background-image: url('/|');">
}
15 = TEXT
15 {
if.isFalse.field = tx_mask_cnt_news_item_teaser_bg
value = <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12 news-tb-item">
}
20 = TEXT
20 {
wrap = <div class="news-tb-item-head">|</div>
field = header
}
25 = CONTENT
25 {
wrap = <div class="categories">|</div>
table = sys_category
select {
# ID der Seite, auf der die Kategorien angelegt sind
pidInList = 0
join = sys_category_record_mm ON (sys_category_record_mm.uid_local=sys_category.uid)
where = sys_category_record_mm.tablenames='tt_content' AND sys_category_record_mm.uid_foreign = ###recorduid###
markers {
recorduid.field = uid
}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = <li class="category {field:title}">|</li>
renderObj.insertData = 1
}
30 = TEXT
30 {
wrap = <div class="news-tb-item-sub">|</div>
field = subheader
}
40 = FILES
40 {
references {
table = tt_content
# Seiten-ID
uid.dataWrap= {field:uid}
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.crop.data = file:current:crop
file.treatIdAsReference = 1
altText.data = file:current:title
params =
wrap = |
}
}
50 = TEXT
50 {
field = bodytext
}
60 = TEXT
60 {
value = Weiter
lang.en = Read
wrap = <div class="morelink-wrapper">|</div>
typolink {
parameter.field = pid
ATagParams = class="morelink"
}
}
}
}
}
子页面?
您在tt_content
上构建了一个选择,因此您拥有第17页的所有CE。
也许你的意思是
lib.newsteaser.20.table = pages
如果您选择页面:
您的标记定义访问当前页面的页面记录(TSFE
),但您需要页面记录的uid,这是您当前的上下文(renderObj
)。
所以正确的标记定义应该是:
pageuid.field = uid
否则(选择tt_content):
你需要使用关系到你当前的记录tt_content
:
where = sys_category_record_mm.tablenames='tt_content' AND sys_category_record_mm.uid_foreign = ###recorduid###
markers.recorduid.field = uid
或者从子页面中选择tt_content(我不知道你是如何从子页面获取记录的,因为你没有选择子页面)并且类别存储在页面中)
where = sys_category_record_mm.tablenames='pages' AND sys_category_record_mm.uid_foreign = ###pageuid###
markers.pageuid.field = pid
tt_content记录的页面存储在字段pid
中
TYPO3如何存储数据?
TYPO3将其数据存储在不同的表中。主要表格是pages
,用于构建网站的页面。这些页面以树形结构。并非所有页面都代表单个前端页面。 TYPO3中的每条记录都存储在“一页”中(分配给pages
record)。存在一个特殊的“页面”,它没有真正的页面,也没有pages
record。它是页面树的根,可以使用带有“唯一标识符”的uid 0.uid
stands的页面进行标识,并且是每个数据记录中的一个字段。为了识别分配给记录的页面,每个数据记录都有一个字段pid
(页面ID)。
因为pages
records有一个字段pid
它给树结构。每个页面都有一个父页面,根页面有(伪)页面0作为父页面。在pages
record中存储了大量信息,但通常没有内容。 (您可以存储背景图像,视觉效果或特殊预览图像以及pages
record中的描述或摘要等SEO信息)
对于内容,存在表tt_content
。在这里,您可以存储文本,(引用)图像或插件配置,以控制例如其他记录的呈现。
对于页面的预告片,您可以实现两种:
1.预告片的所有信息都存储在pages
record中
2.您使用页面的内容,意思是:获取该页面中tt_content
records的信息
使用预告片的典型场景是新闻列表:显示标题和摘要或介绍图像,该图像链接到带有全文的详细视图。
您的代码提醒此场景,与teasers表示的页面菜单无关。
我会以这种方式使用typoscript构建:
建立一个菜单对象(也许special = directory
)
对于每个menuitem,用before
对象替换默认链接,在这里使用当前pages
record的其他字段来构建由预览图像,页面标题,页面摘要组成的链接。
lib.teaserMenu = HMENU
lib.teasermenu {
special = directory
special.value = 123
1 = TMENU
1 {
// remove normal link
doNotShowLink = 1
// build it by myself:
before.cObject = COA
before.cObject {
stdWrap.wrap = <div class="teaser">|</div>
stdWrap.typolink.field = uid
10 = FILES
10 {
:
}
20 = TEXT
20.field = title
20.wrap = <h3>|</h3>
30 = TEXT
30.field = abstract
30.wrap = <p>|</p>
:
}
}