Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend preview for file fields like image etc. in repeatable content items does not work #439

Closed
janamedick opened this issue Nov 2, 2021 · 3 comments

Comments

@janamedick
Copy link

When trying to output a preview view of file fields like media, assets or image in repeatable content items (repetition > content) in the backend, an exception error is displayed ("PHP Warning: count(): Parameter must be an array or an object that implements Countable in..."). I suspect that the relation for the backend preview view is not resolved and instead only the number of stored images/media of the database field is displayed. In repetitions of type "inline" the preview view for file fields works fine.

@nhovratov
Copy link
Collaborator

Hey @janamedick ,

this should work. Which version of Mask do you use?
Mask adds it to the data variable.
Can you show me your backend preview html?

@janamedick
Copy link
Author

Hey @nhovratov,

thanks for your fast reply. I can reproduce the error with a fresh TYPO3 installation: TYPO3 v10.4.21, Mask v7.0.26. I have created a very reduced example:

mask.json:

{
    "tt_content": {
        "elements": {
            "item": {
                "color": "#000000",
                "columns": [
                    "assets"
                ],
                "description": "",
                "icon": "",
                "key": "item",
                "label": "Item",
                "labels": [
                    "assets-field"
                ],
                "shortLabel": "item with assets-Field"
            },
            "wrapper": {
                "color": "#000000",
                "columns": [
                    "tx_mask_items"
                ],
                "description": "",
                "icon": "",
                "key": "wrapper",
                "label": "Wrapper",
                "labels": [
                    "Items"
                ],
                "shortLabel": ""
            }
        },
        "sql": {
            "tx_mask_items": {
                "tt_content": {
                    "tx_mask_items": "int(11) unsigned DEFAULT '0' NOT NULL"
                }
            }
        },
        "tca": {
            "assets": {
                "coreField": 1,
                "key": "assets",
                "name": "file"
            },
            "tx_mask_items": {
                "cTypes": [
                    "mask_item"
                ],
                "config": {
                    "appearance": {
                        "collapseAll": 1,
                        "enabledControls": {
                            "dragdrop": 1
                        },
                        "levelLinksPosition": "top",
                        "showAllLocalizationLink": 1,
                        "showPossibleLocalizationRecords": 1,
                        "useSortable": 1
                    },
                    "foreign_sortby": "sorting",
                    "foreign_table": "tt_content",
                    "overrideChildTca": {
                        "columns": {
                            "colPos": {
                                "config": {
                                    "default": 999
                                }
                            }
                        }
                    },
                    "type": "inline"
                },
                "description": "",
                "key": "items",
                "l10n_mode": "",
                "name": "content"
            }
        }
    }
}

Backend > Templates > Wrapper.html:

<f:if condition="{data.tx_mask_items}">
    <f:for each="{data.tx_mask_items}" as="data_item">
        <f:if condition="{data_item.assets}">
            <f:for each="{data_item.assets}" as="file">
                <f:image image="{file}" width="200" />
            </f:for>
        </f:if>
    </f:for>
</f:if>

@nhovratov
Copy link
Collaborator

Thanks, the example was really helpful!
I even found another related bug.
Thank you very much for your report.

nhovratov added a commit that referenced this issue Nov 3, 2021
InlineHelper->getInlineElements used the field name as the table name
for the child relations. This does only work for inline fields, because
the field name and table are the same. Instead, the provided child
table name must be used.

The same goes for the cType. An inline field of type tt_content has
probably another cType than the parent. This can be fetched from the
data row.

Fixes: #439
(cherry picked from commit b8a7ec0)
nhovratov added a commit that referenced this issue Nov 3, 2021
InlineHelper->getInlineElements used the field name as the table name
for the child relations. This does only work for inline fields, because
the field name and table are the same. Instead, the provided child
table name must be used.

The same goes for the cType. An inline field of type tt_content has
probably another cType than the parent. This can be fetched from the
data row.

Fixes: #439
(cherry picked from commit b8a7ec0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants