Page 1 of 1

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

Posted: Fri Nov 21, 2014 11:23 pm
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

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

Posted: Sat Nov 22, 2014 3:40 pm
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

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

Posted: Mon Nov 24, 2014 8:08 pm
by Jeff
When using @first and @last they shouldn't be within any {if} or other conditional statements.

Thanks,
Jeff

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

Posted: Tue Dec 02, 2014 2:57 am
by blackhawk
Thank you for that tip!