Jump to content

Blocks pulling database records

Featured Replies

Posted

Is it possible to find and use the position of a record in an array to then use the data stored?

At the minute I could do:

{{foreach $records as $record}}

However that is of course all records. What I want to do is use the first record in the array in some way, then use the other records in another way.

In most places, zero-indexed arrays are used, so you can do something like:

{{foreach $records as $idx => $record}}
    {{if $idx == 0}}
        First...
    {{endif}}
    ...

In places where the key is something else, you can track it manually. Something like:

{{$doneFirst = false;}}
{{foreach $records as $record}}
    {{if !$doneFirst}}
        First...
        {{$doneFirst = true;}}
    {{endif}}
    ...

 

  • Author

Thanks, much appreciated.

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.