Jump to content

Blocks pulling database records


MeekelTM

Recommended Posts

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.

Posted

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}}
    ...

 

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...