Search code examples
typo3typoscripttypo3-9.x

TYPO3: How to get only parts of a record?


I want to built a content element with fields for text and images (I'm using the Mask extension for this) and use parts of the contents of it on further pages, for example as teasers.

Is it basically possible to put out only parts of a specific record, e.g. only the text and can an anybody give me a hint or an example how to?

Thank you for your help! Michael


Solution

  • What you are rendering is your selection. In mask you already use only a subselection of all available fields in a tt_content record. It s very complicated for an editor if you use fields in your rendering, that can't be edited.
    Assume you have CE (content element) of type A with some fields which all are filled with data, then you change the type to B which has other fields. As you have not emptied the fields from type A you still can access them and render it in the frontend.

    if you want to render teaser you use only those fields you think what gives you the teaser information.
    In general records are handled complete.

    you can define your own viewhelper which provide you with restricted data or you use typoscript where you do the rendering in typoscript and you have no access to individual fields.

    e.g. you could use a CONTENT object, selecting data from CEs in another page:

    temp.teaser = CONTENT
    temp.teaser {
        table = tt_content
        select {
            // assuming context of a page, like in a menu
            pidInList.field = uid
            orderBy = sorting
            max = 1
        }
        renderObj = COA
        renderObj {
            10 = TEXT
            10.field = header
            10.wrap = <div class="head">|</div>
    
            20 = TEXT
            20.field = bodytext
            20.wrap = <div class="content">|</div>
            20.crop = 100 | ... | 1
    
            wrap = <div class="teaser">|</div>
        }
    }