Daandelange/kirby3-TranslatedLayout

toLayouts() question

Opened this issue · 1 comments

I have a question about the output of content in templates using the toLayouts() function.

Here is a super simple example use case of the plugin.

Notice below how the content of the gallery block in the English translation is empty.

In the panel your plugin is looping through the layouts/columns/blocks and uses the original or the translation correctly in the layouts field.

However, when using toLayouts() the plugin has no effect on the output of the field (I get an empty gallery block).
Is this expected behavior?

Original German, gallery block can not be translated, text block can be translated

Layout:[{
    "attrs":[],
    "columns":[{
        "blocks":[
            {"content":{"images":["file:\/\/pUItlwkKx2BPwkZg"]},"id":"92a42692-4713-4fb0-af51-87e34c8e9910","isHidden":false,"type":"gallery"},
            {"content":{"text":"<p>Some text DE<\/p>"},"id":"d7d234c2-04fc-4404-9dc3-f4c2236e8171","isHidden":false,"type":"text"}
        ],"id":"b861ad97-48ca-4801-9aa7-5be1dd5116c4","width":"1\/1"
    }],"id":"35edf6df-f948-4bf8-a17c-eb32a4cdc7b9"
}]

English translated layout, only text block has been translated

Layout: [{
    "attrs":[],
    "columns":[{
        "blocks":[
            {"content":[],"id":"92a42692-4713-4fb0-af51-87e34c8e9910","isHidden":false,"type":"gallery"},
            {"content":{"text":"<p>Some text EN<\/p>"},"id":"d7d234c2-04fc-4404-9dc3-f4c2236e8171","isHidden":false,"type":"text"}
        ],"id":"b861ad97-48ca-4801-9aa7-5be1dd5116c4","width":"1\/1"}
    ],"id":"35edf6df-f948-4bf8-a17c-eb32a4cdc7b9"
}]

Hello, I haven't investigated looping/rendering the blocks a lot yet.
Right now there's no sanitisation options/methods for parsing content, everything is done on storing the data, then it's simply retrieved by native functions (Cms/Field namespace). So the native toLayout method should work; if not, does your content files get written correctly ? It could be broken, I haven't used this for a while.
However, on the panel side (Form/Field namespace), the panel parses content on retrieval, that's why it could work there.