2

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?

pgampe
  • 4,531
  • 1
  • 20
  • 31

2 Answers2

3

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.

Claus Due
  • 4,166
  • 11
  • 23
  • I changed the error by but, no picture is shown. Is there another error to? – Michael Gnessner Sep 10 '16 at 11:09
  • 1
    The rest seems to be all okay. Maybe you did not override the template files correctly and the partial is not being rendered? – Claus Due Sep 10 '16 at 11:25
  • The partial FalMediaImage is the right or must I change the detail view of my template? – Michael Gnessner Sep 10 '16 at 13:32
  • 1
    That depends completely on your setup, extension versions and extension configuration - I think you should ask this as a new question and include as much as possible of your intended behavior and current setup as possible. – Claus Due Sep 10 '16 at 14:54
0

Sorry , I have worked in the wrong Partial . Not the FalMediaImage need to be adjusted but the FalMediaContainer .

<f:if condition="{media}">
<!-- fal media files -->
  <div class="news-img-wrap">
    <f:for each="{media}" as="mediaElement" iteration="iter">
      <f:if condition="{iter.index} >0">

        <div class="outer">
          <f:if condition="{mediaElement.originalResource.type} == 2">
            <f:render partial="Detail/FalMediaImage" arguments="{mediaElement: mediaElement, settings:settings}"/>
          </f:if>
          <f:if condition="{mediaElement.originalResource.type} == 4">
            <f:render partial="Detail/FalMediaVideo" arguments="{mediaElement: mediaElement, settings:settings}"/>
          </f:if>
          <f:if condition="{mediaElement.originalResource.type} == 5">
            <f:render partial="Detail/FalMediaImage" arguments="{mediaElement: mediaElement, settings:settings}"/>
          </f:if>
        </div>
      </f:if>
    </f:for>
  </div>
</f:if>

Maybe it will help someone else who has the same problem as me ?