Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Esha Noronha <[email protected]>
  • Loading branch information
sofietoft and eshanrnh authored Jun 27, 2024
1 parent aeb6ead commit 2bcd90b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Finally, in Part Three we shall change the blog listing.
* Select *Default.cshtml*.

2. Scroll down to find the `foreach` loop.
3. Declare a new `publicationDate` variable as the first thing with the loop:
3. Declare a new `publicationDate` variable as the first thing within the loop:

```csharp
var publicationDate = post.Value<DateTime>("publicationDate");
Expand All @@ -23,7 +23,7 @@ Finally, in Part Three we shall change the blog listing.
<small class="blogpost-date">@publicationDate.ToLongDateString()</small>
```

* The `ToLongDateString()` method ensures a clean looking date format.
* The ToLongDateString() method is called on the `publicationDate` variable to format it as a long date string.

5. Redefine the `blogposts` variable before the first `div` tag - this will be used for sorting the posts:

Expand All @@ -34,13 +34,17 @@ Finally, in Part Three we shall change the blog listing.
```

* Because we are sorting by a custom property we need to use the generic `Value` method.

{% hint style="info" %}
You can use **Query builder** to construct your queries in a more structured and reusable manner. Use the `UmbracoHelper` or the `IPublishedContentQuery` interface to build queries dynamically. For more information, see the [Querying & Models](https://docs.umbraco.com/umbraco-cms/reference/querying) article.
{% endhint %}
6. Locate the `@foreach` loop, and change `Model.Blostposts` to the variable created above: `blogposts`:

```csharp
@foreach (IPublishedContent post in blogposts)
```

7. *Save* the partial view - a confirmation message should appear confirming that the Partial view has been saved.
7. **Save** the partial view - a confirmation message should appear confirming that the Partial view has been saved.
8. Now view both the Blog overview and the blog posts themselves in the browser to confirm that all is working as expected.

## Summary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ The final piece to the puzzle is adding the partial view that will be rendered w

1. Go to the **Settings** section.

2. Click on **Partial Views** and select **Create...** > **New empty partial view**
2. Click on **Partial Views** and select **Create...** > **New empty partial view**.
3. **Enter a Name** for the partial view. Let's call it: _OpenGraph_
3. Add the standard view model: `@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage`
* We are using compositions and only render this view on pages where the composition exists, which means we need to be a little more specific.
* We only render this view on pages where the composition exists, so we need to be more specific.
4. In the template editor, pass in the specific model you've created by adding `<IOpenGraph>` after the view model.
* Now you can start rendering the meta tags and adding in the values.
5. First add the title property
Expand Down

0 comments on commit 2bcd90b

Please sign in to comment.