Skip to content

Commit 4ef549f

Browse files
authored
Merge pull request #1278 from doenietzomoeilijk/5.0
Update basic "record and records" templating info.
2 parents ad2e70b + 1b3bb94 commit 4ef549f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

docs/templating/record-and-records.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,62 @@ for that matter) are, is to use the `dump()` function:
2424
{{ dump(record) }}
2525
```
2626

27-
<a href="/files/content-example3.png" class="popup"><img src="/files/content-example3.png" width="500"></a>
27+
<a href="/files/4.0.content-example3.png" class="popup"><img src="/files/4.0.content-example3.png" width="500"></a>
2828

2929
As you can see in the screenshot, a record of a ContentType is an `object`.
3030
There are several benefits to this over a regular `array`. We can access the
3131
fields like regular values, but we can also use specific functionality for
3232
every object, without the need to define these separately.
3333

34+
In addition, Bolt ships with some Twig filters and functions to display the
35+
content and all its related fields and values.
36+
3437
You can access regular fields in a record like these examples for either a
3538
`page` or `entry` record:
3639

3740
```twig
3841
{{ page.title }}
3942
{{ page.text }}
4043
41-
Created on {{ entry.datecreated|date('Y-m-d')}}
44+
Created on {{ entry.createdAt|date('Y-m-d')}}
4245
43-
The ContentType for this entry is {{ entry.contenttype.name }},
44-
and it contains {{ entry.contenttype.fields|length }} fields.
46+
The ContentType for this entry is {{ entry.contenttype }},
47+
and it contains {{ entry.fields.count }} fields.
4548
```
4649

4750
The real power comes from using the special functions that are defined for every
4851
content record.
4952

50-
To get a link to the content:
53+
To get a link to the content, use the `link` filter:
5154

5255
```twig
53-
Link: <a href="{{ page.link }}">{{ page.title }}</a>
56+
Link: <a href="{{ page|link }}">{{ page.title }}</a>
5457
```
5558

5659
Get a short excerpt of the record:
5760

5861
```twig
59-
<p>{{ page.excerpt(250) }}</p>
62+
<p>{{ page|excerpt(250) }}</p>
6063
```
6164

6265
Get the next and previous record:
6366

6467
```twig
65-
{% set previous = page.previous() %}
66-
{% set next = page.next() %}
68+
{% set previous = page|previous() %}
69+
{% set next = page|next() %}
6770
```
6871

6972
The next and previous functions allow for additional parameters. For example,
70-
you can base the next record on any field (this is `datepublish` by default),
71-
filtered by a `where` clause, see [using where](content-fetching#using-where)
72-
for more details.
73+
you can base the next record on the ID (the default), but you could also get the
74+
next page by publishing date.
7375

7476
```twig
75-
{% set next = page.next('datepublish', {'status': page.taxonomy.status} ) %}
77+
{% set next = page|next('publishedAt') %}
7678
```
7779

80+
The complete list of available Twig filters for a record can be found
81+
[here](../twig-components/filters) and [here](../twig-components/extras).
82+
7883
### Getting the type of a certain field
7984

8085
If you're iterating over an array of `record.fields`, it's sometimes useful to

0 commit comments

Comments
 (0)