0

I have created a new custom element using the sitepackage builder, created a new table and built the TCA fields and it seemed to be going well, I could save content in my custom element (title, text, images) and find it in my database but when I try to render the content on the front-end I get nothing, not even an error.

I have the following typoscript in my setup (updated after the answer):


tt_content {
    extention_key =< lib.contentElement
    extention_key {
        templateRootPaths.10 = EXT:extention_key/Resources/Private/Templates/ContentElements/
        partialRootPaths.10 = EXT:extention_key/Resources/Private/Partials/ContentElements/
        templateName = mytemplate

        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            10 {
                table = tx_extention_key_items
                pidInList.field = pid
                selectFields = tx_extention_key_items.*
                join = tt_content ON tx_extention_key_items.akkordeon_items_content_relation= tt_content.uid
                orderBy = tt_content.sorting
                as = items
                dataProcessing {
                     10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                     10 {
                         references.fieldName = image
                         as = images
                         treatIdAsReference = 1
                     }
                 }
            }
        }
    }
}

tx_extention_key_items.extention_items_content_relation = tt_content.uid is the condition I have set for the records to be passed to the template and I have alreasy checked the DB and confirmed it indeed is working, I also confirmed that pid is correct.

For my template I have this basic loop (also updated):

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true"></html>


<f:if condition="{items}">
    <f:for each="{items}" as="item">
        <div class="item">
            <h2>{item.title}</h2>
            <p>{item.description}</p>
            <f:if condition="{item.images}">
                <f:for each="{item.images}" as="image">
                    <f:image src="{image.uid}" alt="{image.title}" />
                </f:for>
            </f:if>
        </div>
    </f:for>
</f:if>

<f:debug title="My Debug Statement">{items}</f:debug>


<f:render partial="accordion" arguments="{data: tx_extention_key_items}" />

The issue is not being able to see any content, inspecting using the broweser tool shows empty HTML tags, the debug line returns an array of my items, I can see it has the correct pid and the relation field is the same as the element uid from tt_content that should mean that my content is being passed to the template so I have no idea what's not working, especially when I get no error messege despite having config.debug set to 1

How to fix this? EDIT : After making some changes based on the answers I got I now get an error on my page error:file not found

EDIT 2: after following @Markus advice I changed the line : <f:image src="{image.uid}" alt="{image.title}" /> to <f:image image="{image}" alt="{image.title}" /> and that did it for the images but the title and description still missing I also added the following debug line for items and this is the result<f:debug title="Debug items">{item}</f:debug> thanks for all the help so far. debug statement for items

typolore
  • 3
  • 2

2 Answers2

2

Be aware of your brackets and indention. 20 is outside of dataProcessing where it won't be processed.

And the FilesProcessor needs to be applied to the result of the DatabaseQueryProcessor to be processed for each of your items separately and based on the current item's data.

tt_content {
    extention_key =< lib.contentElement
    extention_key {
        templateRootPaths.10 = EXT:extention_key/Resources/Private/Templates/ContentElements/
        partialRootPaths.10 = EXT:extention_key/Resources/Private/Partials/ContentElements/
        templateName = mytemplate

        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            10 {
                table = tx_extention_key_items
                pidInList.field = pid
                selectFields = tx_extention_key_items.*
                join = tt_content ON tx_extention_key_items.extention_items_content_relation = tt_content.uid
                where = txextention_key_items.akkordeon_items_content_relation = tt_content.uid
                orderBy = tt_content.sorting
                as = items
                dataProcessing {
                     10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                     10 {
                         references.fieldName = image
                         as = images
                         treatIdAsReference = 1
                     }
                 }
            }
        }
    }
}

Details can be found at: https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/ContentObjects/Fluidtemplate/DataProcessing/DatabaseQueryProcessor.html#typoscript

Julian Hofmann
  • 2,081
  • 1
  • 8
  • 16
  • @typolore To make this work in the fluid template, you should be aware of the variables names too. Having images in the TypoScript and image in Fluid won't work. – Jo Hasenau May 02 '23 at 18:18
  • Thank you for the answer, I changed my typoscript and that resulted in images array appearing in the debugging statement, but nothing changed with the live page and my content does not appear, changing the image variable name to images got me a new error: No file found for given UID: 32 – typolore May 02 '23 at 19:33
  • If your field name is `image`, then it will work without any issue. Can you try to remove the where condition and see if you get a response? – Siva May 03 '23 at 06:34
  • @Siva removing the where condition returned a an sql error on the where clause `Column not found: 1054 Unknown column 'tx_extention_key_items.akkordeon_items_content_relation' in 'where clause'` – typolore May 03 '23 at 07:45
  • @typolore okay what I meant is to comment out this line `// where = txextention_key_items.akkordeon_items_content_relation = tt_content.uid` – Siva May 03 '23 at 08:00
  • @Siva yes, I commented out the line `where = tx_extention_key_items.akkordeon_items_content_relation = tt_content.uid` and it got me this error `Column not found: 1054 Unknown column 'tx_extention_key_items.akkordeon_items_content_relation' in 'where clause'` – typolore May 03 '23 at 08:14
  • @typolore If I may ask, did you clear the cache after doing this change? ( I am sure you might have done this, but just asking ) – Siva May 03 '23 at 12:59
  • apparently I did not, after clearing the cache I am now back to the `Oops, an error occurred! No file found for given UID: 32` thanks for the reminder. – typolore May 03 '23 at 13:15
  • @typolore Can you please update your TypoScript in the original post, so that we can see its current version? And also the template code (if also updated). Thank you. – Markus May 04 '23 at 08:24
  • I update my qustion to show the changes I made and the new error I got. – typolore May 04 '23 at 08:46
  • @typolore Thanks for updating. Now, you may try `` instead of ``. Or if that does not work: Try to debug in the inner `` loop above ``: `{image}` – Markus May 05 '23 at 07:36
  • @Markus That did it! for the images at least, title and description still aren't showing – typolore May 05 '23 at 07:45
  • @typolore Nice! You mean `{item.title}` and `{item.description}` do not work? Do you want to show the values you entered for the image object in backend? – Markus May 05 '23 at 08:41
  • @Markus `{item.title} `and`{item.description}` do not work, when I inspect in the broweser I get empty html tags, I have tried changing the selectFields in my typoscript to specify the fields that should be passed but that didn't really change anything. I have updated my question to show the debug statment for items. – typolore May 05 '23 at 08:52
  • @typolore Alright, I now see the problem: There is the `data` missing in your template variable paths. I wrote the solution in my post below to make it more visible for others: [see below](https://stackoverflow.com/questions/76156713/the-contents-of-my-new-custom-element-do-not-appear-in-the-front-end-but-i-can-s/76180318#76180318) – Markus May 05 '23 at 10:16
0

Because the solution is kind of hidden in my comment:

You can use <f:image image="{image}" alt="{image.title}" /> instead of <f:image src="{image.uid}" alt="{image.title}" /> to show the images.

And instead of <h2>{item.title}</h2> and <p>{item.description}</p>, you should use <h2>{item.data.title}</h2> and <p>{item.data.description}</p>.

Markus
  • 81
  • 4
  • 1
    I feel incredibly stupied for not getting this one on my own , it makes so much sense now, thank you for the help, I will be closing the question – typolore May 05 '23 at 10:31
  • You're welcome. In the end it mostly makes sense. – Markus May 05 '23 at 10:32