TYPO3-Headless / headless_news

Adds support for EXT:news to EXT:headless
MIT License
11 stars 18 forks source link

News-Detail run's into an error #5

Closed meincms closed 2 years ago

meincms commented 4 years ago

I sometimes run into an error when customizing the fluid template. I'm not sure where to have an eye on, because for me it seems a bit random. A thought: Probably i run into a limitation...?

List.html can be extended very well.... (same change which doesn't work in this example, works well in List.html, but not in Detail.html).

this one here works well:

date: {
    day: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'j\\\')}\')}',
    month: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'M\\\')}\')}',
    year: ''
},

following section is leading to an error:

date: {
    day: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'j\\\')}\')}',
    month: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'M\\\')}\')}',
    year: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'Y\\\')}\')}'
},

That's the whole script which works now

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:n="http://typo3.org/ns/GeorgRinger/News/ViewHelpers"
      data-namespace-typo3-fluid="true">
<f:spaceless>
    <f:format.raw>
        <f:if condition="{settings.excludeAlreadyDisplayedNews}">
            <f:then>
                <n:format.nothing>
                    <n:excludeDisplayedNews newsItem="{newsItem}"/>
                </n:format.nothing>
            </f:then>
        </f:if>
        <f:format.json value="{
        detail: {
            uid: newsItem.uid,
            title: newsItem.title,
            teaser: newsItem.teaser,
            isTopNews: newsItem.istopnews,
            bodytext: '{newsItem.bodytext -> f:format.html(parseFuncTSPath: \'lib.parseFunc_links\')}',
            tstamp: '{f:if(condition: newsItem.tstamp, then: \'{newsItem.tstamp -> f:format.date(format: \\\'d\.m\.Y\\\')}\')}',
            datetime: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'d\.m\.Y\\\')}\')}',
            date_html: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'Y\-m\-d\\\')}\')}',
            date: {
                day: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'j\\\')}\')}',
                month: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'M\\\')}\')}',
                year: '{f:if(condition: newsItem.datetime, then: \'{newsItem.datetime -> f:format.date(format: \\\'Y\\\')}\')}'
            },
            archive: '{f:if(condition: newsItem.archive, then: \'{newsItem.archive -> f:format.date(format: \\\'M\ d\ Y\\\')}\')}',
            author: {
              author: newsItem.author,
              authorEmail: newsItem.authorEmail
            },
            media: '{f:render(partial: \'Files\', arguments: \'{files: newsItem.media, view: \\\'detail\\\'}\') -> headless:format.json.decode()}',
            falRelatedFiles: '{f:render(partial: \'Files\', arguments: \'{files: newsItem.falRelatedFiles, view: \\\'detail\\\', type: \\\'relatedFiles\\\'}\') -> headless:format.json.decode()}',
            categories: '{f:render(partial: \'Categories\', arguments: \'{categories: newsItem.categories}\') -> headless:format.json.decode()}',
            tags: '{f:render(partial: \'Tags\', arguments: \'{tags: newsItem.tags}\') -> headless:format.json.decode()}',
            metaData: {
              keywords: newsItem.keywords,
              description: newsItem.description,
              alternativeTitle: newsItem.alternativeTitle
            },
            pathSegment: newsItem.pathSegment,
            canonical: '{f:uri.page(pageUid: newsItem.canonical, additionalParams: \'{tx_news_pi1: \\\'{news: newsItem.uid, action: \\\\\\\'detail\\\\\\\', controller: \\\\\\\'News\\\\\\\'}\\\'}\')}'
        },
        settings: {
          templateLayout: settings.templateLayout,
          action: 'detail'
        },
        contentElements: '{f:render(partial: \'ContentElements\', arguments: \'{contentElementIdList: newsItem.contentElementIdList}\') -> headless:format.json.decode()}'
        }"
        />
    </f:format.raw>
</f:spaceless>
lukaszuznanski commented 4 years ago

Looks like some kind of limitation. I will dig into this topic.

lukaszuznanski commented 4 years ago

@meincms looks like it's max lines of code limitation of value="" property. Please set your statement to f:variable, and then add only variable.