Skip to content

GoogleSheets

Snippet for displaying data from the table

Parameters for the snippet:

NameDescription
spreadsheetIdID of the spreadsheet.
rangeSheet name of the spreadsheet, can also include a cell range for selection (Mylist!A1:J10)
ignoreHeadersSkip the first row in the table. Possible values: 1 or 0
keysVariable names, separated by commas.
whereCondition for filtering results.
sortbySorting field. Default: id
sortdirSorting direction. Default: asc
limitLimit on the selection. Default: 0
tplChunk for displaying results. If not specified, an array of results will be displayed.

Example

php
<table class="table">
    <tbody>
        {'!GoogleSheets' | snippet: [
            'spreadsheetId' => '16eyRFL94Dtqm8QQjYzw6gsY2iMIO5Ij30lBXVIpKGbw',
            'range' => 'FormItForm',
            'ignoreHeaders' => 1,
            'keys' => 'id,form,ip,date,name,email',
            'where' => ['form' => 'Brevo'],
            'sortby' => 'date',
            'sortdir' => 'desc',
            'limit' => 5,
            'tpl' => 'formList'
        ]}
    </tbody>
</table>

Chunk formList

html
<tr>
    <td>[[+id]]</td>
    <td>[[+form]]</td>
    <td>[[+ip]]</td>
    <td>[[+date]]</td>
    <td>[[+name]]</td>
    <td>[[+email]]</td>
</tr>

keys

You can skip certain values if they are not needed. For example, if you specify id,form,ip,,,email, then date and name will not be displayed.

php
<table class="table">
    <tbody>
        {'!GoogleSheets' | snippet: [
            'spreadsheetId' => '16eyRFL94Dtqm8QQjYzw6gsY2iMIO5Ij30lBXVIpKGbw',
            'range' => 'FormItForm',
            'ignoreHeaders' => 1,
            'keys' => 'id,form,ip,,,email',
            'where' => ['form' => 'Brevo'],
            'sortby' => 'date',
            'sortdir' => 'desc',
            'limit' => 5,
            'tpl' => 'formList'
        ]}
    </tbody>
</table>

Error

However, if you specify id,form,ip,email, the field email will display the date (from the field date).

© GoogleSheets 2019-present