Skip to content

Commit 49dba55

Browse files
authored
Merge pull request #543 from james0r/patch-1
Update blog-templates.md
2 parents 6182ae5 + 5524907 commit 49dba55

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

docs/getting-started-tutorial/build/blog-templates.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ If you were to go back into the control panel and create some more posts, you co
120120

121121
#### Feature Image
122122

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:
124124

125125
```twig{4,15-19}
126126
{% extends '_layout' %}
@@ -187,15 +187,15 @@ If the lack of styles makes it difficult to evaluate whether you are staying on
187187

188188
#### Topics
189189

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!
191191

192192
Just below the existing `set` tag, add another one to fetch the attached categories:
193193

194194
```twig{3-4}
195195
{% set featureImage = entry.featureImage.one() %}
196196
197197
{# Load attached topics: #}
198-
{% set topics = entry.topics.all() %}
198+
{% set topics = entry.postCategories.all() %}
199199
```
200200

201201
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
239239

240240
#### Post Content
241241

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:
243243

244244
1. Load matrix blocks via the `postContent` field handle and store them in a variable;
245245
1. Loop over those blocks with a `{% for %}` tag;

docs/getting-started-tutorial/build/optimization.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We have a host of other ideas for [next steps](../more/README.md) if you would p
1010

1111
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.
1212

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`:
1414

1515
```twig
1616
{% for post in posts %}
@@ -34,7 +34,7 @@ We’ll start by taking the entire `for` loop from `templates/blog/_index.twig`
3434
{% endfor %}
3535
```
3636

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`):
3838

3939
```twig
4040
{% include 'blog/_feed' %}

docs/getting-started-tutorial/configure/resources.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ Assets are organized into _volumes_, which sit on top of a _filesystem_. Filesys
7676

7777
We’ll create a local Asset Volume within the web root for blog post images:
7878

79-
1. In the control panel, navigate to **Settings****Assets**.
80-
1. Click **+ New volume**.
81-
1. Enter “Images” in the **Name** field <Poi label="A" target="newVolume" id="volumeName" />.
82-
1. Click the **Asset Filesystem** menu <Poi label="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 <Poi label="A" target="newVolume" id="volumeName" />;
82+
1. Click the **Asset Filesystem** menu <Poi label="C" target="newVolume" id="volumeFsMenu" /> and select **Create a new filesystem…**;
8383

8484
Within the slideout that opens, provide these settings:
8585

@@ -116,12 +116,12 @@ The second resource we need to create is a group for our blog’s _categories_.
116116
<img src="../images/new-category-group.png" alt="Screenshot of new category group fields" />
117117
</BrowserShot>
118118

119-
1. Navigate to **Settings** and choose **Categories**.
120-
1. Choose **+ New category group**.
121-
1. In the **Name** <Poi label="A" target="newCategoryGroup" id="name" /> field, enter “Topics”.
122-
1. In the **Max Levels** <Poi label="C" target="newCategoryGroup" id="levels" /> field, enter `1`.
123-
1. Set the **Category URI Format** <Poi label="D" target="newCategoryGroup" id="uri" /> to `blog/topic/{slug}`.
124-
1. Set the **Template** <Poi label="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** <Poi label="A" target="newCategoryGroup" id="name" /> field, enter “Topics”;
122+
1. In the **Max Levels** <Poi label="C" target="newCategoryGroup" id="levels" /> field, enter `1`;
123+
1. Set the **Category URI Format** <Poi label="D" target="newCategoryGroup" id="uri" /> to `blog/topic/{slug}`;
124+
1. Set the **Template** <Poi label="E" target="newCategoryGroup" id="template" /> to `blog/_topic`;
125125
1. **Save** <Poi label="F" target="newCategoryGroup" id="save" /> the category group.
126126

127127
## Custom Fields
@@ -143,7 +143,7 @@ The post summary will be entered in a _plain text_ field.
143143

144144
1. Click **+ New Field**;
145145
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;
147147
1. Enable **Allow line breaks**;
148148
1. Set the revealed **Initial Rows** field to `1`;
149149
1. Save the field.
@@ -173,7 +173,7 @@ Posts’ primary images will be added to an _asset_ field.
173173
</BrowserShot>
174174

175175
1. Click **+ New Field**;
176-
1. Enter “Feature Image” into the **Name** <Poi label="A" target="newAssetField" id="name" /> field;
176+
1. Enter “Feature Image” into the **Name** <Poi label="A" target="newAssetField" id="name" /> field (and note that Craft automatically generates a **Handle** of `featureImage`);
177177
1. Select **Assets** from the **Field Type** <Poi label="C" target="newAssetField" id="type" /> menu—the rest of the page will be updated with options specific to asset fields;
178178
1. Tick **Restrict assets to a single location?** <Poi label="D" target="newAssetField" id="restrict" />;
179179
1. Select the **Images** volume from the revealed **Asset Location** <Poi label="E" target="newAssetField" id="location" /> menu;
@@ -188,7 +188,7 @@ Posts’ primary images will be added to an _asset_ field.
188188
Our _topics_ field only needs a couple of options:
189189

190190
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`);
192192
1. Choose “Categories” from the **Field Type** menu—the rest of the page will be updated with options specific to categories fields;
193193
1. Choose “Topics” from the **Source** menu (it will probably be selected, already);
194194
1. Save the field.
@@ -220,7 +220,7 @@ Matrix fields are inherently a bit more complex than other field types, because
220220
</BrowserShot>
221221

222222
1. Click **+ New Field**;
223-
1. Enter “Post Content” in the **Name** <Poi label="A" target="newMatrixField" id="name" /> field;
223+
1. Enter “Post Content” in the **Name** <Poi label="A" target="newMatrixField" id="name" /> field (and note that Craft automatically generates a **Handle** of `postContent`);
224224
1. Choose “Matrix” from the **Field Type** <Poi label="C" target="newMatrixField" id="type" /> menu—the rest of the page will be updated with options specific to matrix fields;
225225
1. Within the **Configuration** <Poi label="D" target="newMatrixField" id="config" /> space, use the **+ New block type** button to create two _block types_:
226226

0 commit comments

Comments
 (0)