如何显示与所有类别标题关联的记录

问题描述 投票:0回答:1

[在网站上,各种记录将作为预告输出。每条记录被分配到一个或多个类别。在预告片中,应显示分配给相应记录的所有类别的标题。

我用Typoscript(见下文)进行了尝试,在其中我通过JOIN将sys_category和sys_category_record_mm的数据库查询链接到tt_content。

但是现在对于分配了多个类别的记录,相应的预告片将输出多次,即每个类别一次。

流体:

<f:if condition="{data.tx_mask_cnt_mag_teaser_records}">
    <f:for each="{data.tx_mask_cnt_mag_teaser_records}" as="data_item">
        <f:cObject typoscriptObjectPath="lib.magteaser" data="{dsuid: data_item.uid, recid: data_item.records, reclimit: 2, tstype: 1, syscats: data.tx_mask_cnt_mag_teaser_cats}" />
    </f:for>
</f:if>

打字稿:

lib.magteaser = COA
lib.magteaser {

    wrap = |

    5 = LOAD_REGISTER
    5 {
        dTstype.data = field:tstype  // Different Teaser-Types
        dSyscats.data = field:syscats  // List of all categories to consider
    }

    10 = CONTENT
    10 {
        table = tt_content
        select {
            pidInList = 13  // Folder in which the records are stored
            uidInList.data = field:recid
            recursive = 2

            selectFields.dataWrap = *, FIND_IN_SET(`tt_content`.`uid`,'{field:recid}') AS reclist_sortby
            join = sys_category_record_mm ON (sys_category_record_mm.uid_foreign = tt_content.uid) JOIN sys_category ON (sys_category_record_mm.uid_local = sys_category.uid)

            where = tt_content.hidden=0
            where = tt_content.CType='mask_cnt_textpic_uni'

            where.data = field:syscats
            # where.intval = 1
            where.wrap = sys_category_record_mm.uid_local IN (|)

            orderBy = reclist_sortby
        }

        renderObj = COA
        renderObj {

            5 = LOAD_REGISTER
            5 {
                # Count variable for a CASE (see below) to format the first data record differently from the remaining data records.
                dsCounter.stdWrap.dataWrap = {register:dsCounter} + 1
                dsCounter.prioriCalc = intval
            }

            10 = CASE
            10 {
                key.data = register:dTstype

                default = COA
                default {
                    wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>
                    [...]
                }

                # 1 Titelbild und 2 Standard-Teaser
                1 = COA
                1 {
                    wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>
                    [...]
                }

                # 1 Top-Teaser und 2 Standard-Teaser
                2 = COA
                2 {

                    10 = CASE
                    10 {
                        key.data = register:dsCounter

                        # Standard-Teaser
                        default = COA
                        default {
                            wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>

                            10 = TEXT
                            10 {
                                wrap = Kategorie (def): |
                                value.dataWrap = {field:title}
                            }

                            [...]

                        }

                        # Top-Teaser
                        1 = COA
                        1 {
                            wrap = <div class="col-12 magteaser-top">|</div>

                            10 = TEXT
                            10 {
                                wrap = Kategorie (1): |
                                value.dataWrap = {field:title}
                            }

                            [...]

                        }

                    }

                }

            }

        }

    }

}

有人对我有解决问题的建议吗?预先非常感谢您的帮助!

Typo3 V.9.5.8

typo3 categories record typoscript teaser
1个回答
0
投票

通过联接,您将生成一个矩阵,每个组合都有一个“记录”。

正确的处理方法是处理renderObj中的多个类别:构建一个零件,在该零件上打印此tt_content记录的所有类别。

概念结构:

10 = CONTENT
10 {
    table = tt_content
    select {
          :
          // without JOIn
          :
    }

    renderObj = COA
    renderObj {

        :

        50 = CONTENT
        50 {
            table = sys_categories
            SELECT {
                join = sys_category_record_mm ON (sys_category_record_mm.uid_foreign = ###CONTENT_UID###) AND (sys_category_record_mm.uid_local = sys_category.uid)

                markers {
                    // context is current tt_content record:  
                    CONTENT_UID.field = uid
                }
            }
            renderObj = TEXT
            renderObj.field = title
            renderObj.wrap =  || ,|
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.