[solved]Having trouble getting the @first and @last values

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

[solved]Having trouble getting the @first and @last values

Post by blackhawk »

I am using CMSMS 1.11.3
I have the following code in my news detail template...

Code: Select all

{if isset($entry->fields)} 
{foreach $entry->fields as $field}

{if $field->type == 'file'}

{if $field->name|strpos:"photo" !== false}

{if $field->displayvalue != ''}

{if $field@first}
top line for last
{/if}

<li><img src="{$entry->file_location}/{$field->displayvalue}"/></li>

{if $field@last}
bottom line for last
{/if}

{/if}
{/if}
{/if}

{/foreach}
{/if}
I can see my

Code: Select all

<li>
value populated in the browser. that is the result of a in image upload for a specific news article. But the DOM is not loading anything (I checked through developer tools for chrome), for

Code: Select all

@first
or

Code: Select all

@last
. I tried doing @index and @key and they work! but for some reason first and last do not show anything. What would be some reasons for this?

thanks for any advice
Last edited by blackhawk on Sat Nov 22, 2014 3:41 pm, edited 1 time in total.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: Having trouble getting the @first and @last values to sh

Post by blackhawk »

I know realize I have other entries other than file types I am pulling, which is probably why my "fields" is not @first or @last when using the foreach loop.

according to my @index, the first field value is always 2
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: [solved]Having trouble getting the @first and @last valu

Post by Jeff »

When using @first and @last they shouldn't be within any {if} or other conditional statements.

Thanks,
Jeff
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: [solved]Having trouble getting the @first and @last valu

Post by blackhawk »

Thank you for that tip!
Post Reply

Return to “The Lounge”