簡體   English   中英

Typo3 - 訪問不同頁面上內容元素的圖像?

[英]Typo3 - access image of content element on a different page?

我正在開發 typo3 v. 10.4.13 站點。 我想要實現的是:我有一個包含自定義內容元素的頁面,並希望在不同的頁面上列出這些元素的一些信息。 內容元素存儲一些文本、integer 值和圖像。 到目前為止,我可以訪問所有文本和整數:我使用 vhs viewhelper 的 v:content.get 來獲取另一頁的 object 並在“pi_flexform”字段中找到請求的信息為 xml。 我用一些簡單的 php 給我寫了一個自定義視圖助手,它將我轉換成一個關聯數組,我可以在流體中使用它。 (也許有更簡單的方法可以做到這一點?)

但我的主要問題是:我還沒有找到如何訪問元素的圖像。 vhs 僅在“圖像”字段中返回我 integer(可能沒有圖像 id - 它始終為 1 或 0)和 pi_flexform 字段 xml 中的相同值。 typo3 如何/在哪里存儲與元素一起使用哪個圖像的信息? 我怎樣才能訪問這些信息? 抱歉,如果這是一個愚蠢的問題 - 我對 typo3 還沒有太多經驗。 非常感謝您提前提供的任何幫助!

內容元素的圖像字段 xml 定義為:

<navpic>
    <TCEforms>
        <label>Image</label>
        <config>
            <type>inline</type>
            <maxitems>1</maxitems>
            <foreign_table>sys_file_reference</foreign_table>
            <foreign_table_field>tablenames</foreign_table_field>
            <foreign_label>uid_local</foreign_label>
            <foreign_sortby>sorting_foreign</foreign_sortby>
            <foreign_field>uid_foreign</foreign_field>
            <foreign_selector>uid_local</foreign_selector>
            <foreign_selector_fieldTcaOverride>
                <config>
                    <appearance>
                        <elementBrowserType>file</elementBrowserType>
                        <elementBrowserAllowed>gif,jpg,jpeg,png,svg</elementBrowserAllowed>
                    </appearance>
                </config>
            </foreign_selector_fieldTcaOverride>
            <foreign_types type="array">
                <numIndex index="0">
                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                </numIndex>
                <numIndex index="2">
                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                </numIndex>
            </foreign_types>
            <foreign_match_fields>
                <fieldname>image</fieldname>
            </foreign_match_fields>
            <appearance type="array">
                <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                <headerThumbnail>
                    <field>uid_local</field>
                    <height>64</height>
                    <width>64</width>
                </headerThumbnail>
                <enabledControls>
                    <info>1</info>
                    <new>0</new>
                    <dragdrop>0</dragdrop>
                    <sort>1</sort>
                    <hide>0</hide>
                    <delete>1</delete>
                    <localize>1</localize>
                </enabledControls>
                <createNewRelationLinkTitle>LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference
                                    </createNewRelationLinkTitle>
            </appearance>
            <behaviour>
                <localizationMode>select</localizationMode>
                <localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
            </behaviour>
            <overrideChildTca>
                <columns type="array">
                    <uid_local type="array">
                        <config type="array">
                            <appearance type="array">
                                <elementBrowserType>file</elementBrowserType>
                                <elementBrowserAllowed>gif,jpg,jpeg,png,svg</elementBrowserAllowed>
                            </appearance>
                        </config>
                    </uid_local>
                </columns>
                <types type="array">
                    <numIndex index="2">
                        <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette </showitem>
                    </numIndex>
                </types>
            </overrideChildTca>
        </config>
    </TCEforms>
</navpic>

Oehm... 為什么要通過 flexform 定義內容? tt_content 有一個圖像列(如果已經使用,您可以擴展該表)。

在此更改之后,應該可以通過 DataProcessors 收集所需的數據。

兩者的基礎知識都可以在這里找到: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.ZAFC365FDC70D5FC786

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM