You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started-tutorial/build/blog-templates.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ If you were to go back into the control panel and create some more posts, you co
120
120
121
121
#### Feature Image
122
122
123
-
Let’s output the image we attached via the “Feature Image” asset field. That field had a handle of `featureImage`, so it will be available on the `entry` variable as `entry.featureImage`, just like the title was:
123
+
Let’s output the image we attached via [the “Feature Image” asset field](../configure/resources.md#feature-image). That field had a handle of `featureImage`, so it will be available on the `entry` variable as `entry.featureImage`, just like the title was:
124
124
125
125
```twig{4,15-19}
126
126
{% extends '_layout' %}
@@ -187,15 +187,15 @@ If the lack of styles makes it difficult to evaluate whether you are staying on
187
187
188
188
#### Topics
189
189
190
-
Let’s add some more metadata to the top of our post. Our content model included a category field called **Topics**, which we can access in a really similar way to the feature image!
190
+
Let’s add some more metadata to the top of our post. Our content model included a [category field](../configure/resources.md#categoriestopics) called **Topics**, which we can access in a really similar way to the feature image!
191
191
192
192
Just below the existing `set` tag, add another one to fetch the attached categories:
193
193
194
194
```twig{3-4}
195
195
{% set featureImage = entry.featureImage.one() %}
196
196
197
197
{# Load attached topics: #}
198
-
{% set topics = entry.topics.all() %}
198
+
{% set topics = entry.postCategories.all() %}
199
199
```
200
200
201
201
Because we’re allowing authors to attach multiple topics to a post, we’ve used `.all()` to fetch _all_ of them, instead of just _one_. This is important, because we will treat `topics` (plural) a little bit differently from `featureImage` (singular).
@@ -239,7 +239,7 @@ If you pasted this into `templates/blog/_entry.twig` and the indentation got mes
239
239
240
240
#### Post Content
241
241
242
-
Let’s output the post content stored in our Matrix field. This process starts in a familiar way:
242
+
Let’s output the [post content](../configure/resources.md#post-content) stored in our Matrix field. This process starts in a familiar way:
243
243
244
244
1. Load matrix blocks via the `postContent` field handle and store them in a variable;
Copy file name to clipboardExpand all lines: docs/getting-started-tutorial/build/optimization.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ We have a host of other ideas for [next steps](../more/README.md) if you would p
10
10
11
11
When building the blog and topic index pages, there was a lot of repeated code involved with outputting the post previews. Twig’s `include` tag can help us reduce that repetition by extracting it into a separate template, and referencing it in both places.
12
12
13
-
We’ll start by taking the entire `for` loop from `templates/blog/_index.twig` and moving it to a new file, `templates/blog/_feed.twig`:
13
+
We’ll start by taking the entire `for` loop from `templates/blog/index.twig` and moving it to a new file, `templates/blog/_feed.twig`:
14
14
15
15
```twig
16
16
{% for post in posts %}
@@ -34,7 +34,7 @@ We’ll start by taking the entire `for` loop from `templates/blog/_index.twig`
34
34
{% endfor %}
35
35
```
36
36
37
-
In place of that block of code in `templates/blog/_index.twig`, `include` the new template (then make the same change to `templates/blog/_topic.twig`):
37
+
In place of that block of code in `templates/blog/index.twig`, `include` the new template (then make the same change to `templates/blog/_topic.twig`):
Copy file name to clipboardExpand all lines: docs/getting-started-tutorial/configure/resources.md
+14-14
Original file line number
Diff line number
Diff line change
@@ -76,10 +76,10 @@ Assets are organized into _volumes_, which sit on top of a _filesystem_. Filesys
76
76
77
77
We’ll create a local Asset Volume within the web root for blog post images:
78
78
79
-
1. In the control panel, navigate to **Settings** → **Assets**.
80
-
1. Click **+ New volume**.
81
-
1. Enter “Images” in the **Name** field <Poilabel="A"target="newVolume"id="volumeName" />.
82
-
1. Click the **Asset Filesystem** menu <Poilabel="C"target="newVolume"id="volumeFsMenu" /> and select **Create a new filesystem…**
79
+
1. In the control panel, navigate to **Settings** → **Assets**;
80
+
1. Click **+ New volume**;
81
+
1. Enter “Images” in the **Name** field <Poilabel="A"target="newVolume"id="volumeName" />;
82
+
1. Click the **Asset Filesystem** menu <Poilabel="C"target="newVolume"id="volumeFsMenu" /> and select **Create a new filesystem…**;
83
83
84
84
Within the slideout that opens, provide these settings:
85
85
@@ -116,12 +116,12 @@ The second resource we need to create is a group for our blog’s _categories_.
116
116
<imgsrc="../images/new-category-group.png"alt="Screenshot of new category group fields" />
117
117
</BrowserShot>
118
118
119
-
1. Navigate to **Settings** and choose **Categories**.
120
-
1. Choose **+ New category group**.
121
-
1. In the **Name** <Poilabel="A"target="newCategoryGroup"id="name" /> field, enter “Topics”.
122
-
1. In the **Max Levels** <Poilabel="C"target="newCategoryGroup"id="levels" /> field, enter `1`.
123
-
1. Set the **Category URI Format** <Poilabel="D"target="newCategoryGroup"id="uri" /> to `blog/topic/{slug}`.
124
-
1. Set the **Template** <Poilabel="E"target="newCategoryGroup"id="template" /> to `blog/_topic`.
119
+
1. Navigate to **Settings** and choose **Categories**;
120
+
1. Choose **+ New category group**;
121
+
1. In the **Name** <Poilabel="A"target="newCategoryGroup"id="name" /> field, enter “Topics”;
122
+
1. In the **Max Levels** <Poilabel="C"target="newCategoryGroup"id="levels" /> field, enter `1`;
123
+
1. Set the **Category URI Format** <Poilabel="D"target="newCategoryGroup"id="uri" /> to `blog/topic/{slug}`;
124
+
1. Set the **Template** <Poilabel="E"target="newCategoryGroup"id="template" /> to `blog/_topic`;
125
125
1.**Save** <Poilabel="F"target="newCategoryGroup"id="save" /> the category group.
126
126
127
127
## Custom Fields
@@ -143,7 +143,7 @@ The post summary will be entered in a _plain text_ field.
143
143
144
144
1. Click **+ New Field**;
145
145
1. Enter “Summary” into the **Name** field;
146
-
1. Enter “Summaries should be one or two sentences.” in the **Default Instructions** field to give authors a hint about the field’s intended usage.
146
+
1. Enter “Summaries should be one or two sentences.” in the **Default Instructions** field to give authors a hint about the field’s intended usage;
147
147
1. Enable **Allow line breaks**;
148
148
1. Set the revealed **Initial Rows** field to `1`;
149
149
1. Save the field.
@@ -173,7 +173,7 @@ Posts’ primary images will be added to an _asset_ field.
173
173
</BrowserShot>
174
174
175
175
1. Click **+ New Field**;
176
-
1. Enter “Feature Image” into the **Name** <Poilabel="A"target="newAssetField"id="name" /> field;
176
+
1. Enter “Feature Image” into the **Name** <Poilabel="A"target="newAssetField"id="name" /> field (and note that Craft automatically generates a **Handle** of `featureImage`);
177
177
1. Select **Assets** from the **Field Type** <Poilabel="C"target="newAssetField"id="type" /> menu—the rest of the page will be updated with options specific to asset fields;
178
178
1. Tick **Restrict assets to a single location?** <Poilabel="D"target="newAssetField"id="restrict" />;
179
179
1. Select the **Images** volume from the revealed **Asset Location** <Poilabel="E"target="newAssetField"id="location" /> menu;
@@ -188,7 +188,7 @@ Posts’ primary images will be added to an _asset_ field.
188
188
Our _topics_ field only needs a couple of options:
189
189
190
190
1. Click **+ New Field**;
191
-
1. Enter “Post Categories” into the **Name** field;
191
+
1. Enter “Post Categories” into the **Name** field (and note that Craft automatically generates a **Handle** of `postCategories`);
192
192
1. Choose “Categories” from the **Field Type** menu—the rest of the page will be updated with options specific to categories fields;
193
193
1. Choose “Topics” from the **Source** menu (it will probably be selected, already);
194
194
1. Save the field.
@@ -220,7 +220,7 @@ Matrix fields are inherently a bit more complex than other field types, because
220
220
</BrowserShot>
221
221
222
222
1. Click **+ New Field**;
223
-
1. Enter “Post Content” in the **Name** <Poilabel="A"target="newMatrixField"id="name" /> field;
223
+
1. Enter “Post Content” in the **Name** <Poilabel="A"target="newMatrixField"id="name" /> field (and note that Craft automatically generates a **Handle** of `postContent`);
224
224
1. Choose “Matrix” from the **Field Type** <Poilabel="C"target="newMatrixField"id="type" /> menu—the rest of the page will be updated with options specific to matrix fields;
225
225
1. Within the **Configuration** <Poilabel="D"target="newMatrixField"id="config" /> space, use the **+ New block type** button to create two _block types_:
0 commit comments