Search code examples
typo3fluidtypo3-7.6.xtx-news

Tx_news detail view skip first picture


I want to render a news item from the News extension, but in the detail view I want to render all images except the first image. I have tried this, seek a solution through a iteration, but somewhere is still a fault has occurred.

The code is:

{namespace n=GeorgRinger\News\ViewHelpers}

<f:for each="{media}" as="mediaElement" iteration="iter">
  <f:if condition="{iter.index}" >1>
    <div class="mediaelement mediaelement-image">
      <f:if condition="{mediaElement.link}">
        <f:then>
          <f:link.page pageUid="{mediaElement.link}" target="{n:targetLink(link:mediaElement.link)}">
            <f:image image="{mediaElement}" title="{mediaElement.title}" alt="{mediaElement.alternative}" maxWidth="{settings.detail.media.image.maxWidth}" maxHeight="{settings.detail.media.image.maxHeight}" />
          </f:link.page>
        </f:then>
        <f:else>
          <f:if condition="{settings.detail.media.image.lightbox.enabled}">
            <f:then>
              <a href="{f:uri.image(image:'{mediaElement}', width:'{settings.detail.media.image.lightbox.width}', height:'{settings.detail.media.image.lightbox.height}')}" title="{mediaElement.title}" class="{settings.detail.media.image.lightbox.class}" rel="{settings.detail.media.image.lightbox.rel}">
                <f:image image="{mediaElement}" title="{mediaElement.title}" alt="{mediaElement.alternative}" maxWidth="{settings.detail.media.image.maxWidth}" maxHeight="{settings.detail.media.image.maxHeight}" />
              </a>
            </f:then>
            <f:else>
              <f:image image="{mediaElement}" title="{mediaElement.title}" alt="{mediaElement.alternative}" maxWidth="{settings.detail.media.image.maxWidth}" maxHeight="{settings.detail.media.image.maxHeight}" />
            </f:else>
          </f:if>
        </f:else>
      </f:if>
    </div>
    <f:if condition="{mediaElement.description}">
      <p class="news-img-caption">
        {mediaElement.description}
      </p>
    </f:if>
  </f:if>
</f:else>

Perhaps someone is able to help?


Solution

  • You have a syntax error in your f:if:

    <f:if condition="{iter.index}" >1>
    

    Should be:

    <f:if condition="{iter.index} > 1">
    

    (quote misplaced - whitespace after the > is just for prettiness.