@@ -24,57 +24,62 @@ for that matter) are, is to use the `dump()` function:
24
24
{{ dump(record) }}
25
25
```
26
26
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 >
28
28
29
29
As you can see in the screenshot, a record of a ContentType is an ` object ` .
30
30
There are several benefits to this over a regular ` array ` . We can access the
31
31
fields like regular values, but we can also use specific functionality for
32
32
every object, without the need to define these separately.
33
33
34
+ In addition, Bolt ships with some Twig filters and functions to display the
35
+ content and all its related fields and values.
36
+
34
37
You can access regular fields in a record like these examples for either a
35
38
` page ` or ` entry ` record:
36
39
37
40
``` twig
38
41
{{ page.title }}
39
42
{{ page.text }}
40
43
41
- Created on {{ entry.datecreated |date('Y-m-d')}}
44
+ Created on {{ entry.createdAt |date('Y-m-d')}}
42
45
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.
45
48
```
46
49
47
50
The real power comes from using the special functions that are defined for every
48
51
content record.
49
52
50
- To get a link to the content:
53
+ To get a link to the content, use the ` link ` filter :
51
54
52
55
``` twig
53
- Link: <a href="{{ page. link }}">{{ page.title }}</a>
56
+ Link: <a href="{{ page| link }}">{{ page.title }}</a>
54
57
```
55
58
56
59
Get a short excerpt of the record:
57
60
58
61
``` twig
59
- <p>{{ page. excerpt(250) }}</p>
62
+ <p>{{ page| excerpt(250) }}</p>
60
63
```
61
64
62
65
Get the next and previous record:
63
66
64
67
``` twig
65
- {% set previous = page. previous() %}
66
- {% set next = page. next() %}
68
+ {% set previous = page| previous() %}
69
+ {% set next = page| next() %}
67
70
```
68
71
69
72
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.
73
75
74
76
``` twig
75
- {% set next = page. next('datepublish', {'status': page.taxonomy.status} ) %}
77
+ {% set next = page| next('publishedAt' ) %}
76
78
```
77
79
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
+
78
83
### Getting the type of a certain field
79
84
80
85
If you're iterating over an array of ` record.fields ` , it's sometimes useful to
0 commit comments