Skip to content

Issue with Displaying Post URLs after Overriding Post Retrieval #56

Answered by WebVPF
01Kuzma asked this question in Q&A
Discussion options

You must be logged in to vote

In the Winter.Blog plugin, the Post model does not have a url field or property.

If you have a static entry path, you can use the slug field:

<a href="/path/{{ post.slug }}" class="hero-link">
    <h4>{{ post.title }}</h4>
</a>

The Post model also has a getUrlParams method, which returns an array of parameters for forming the URL

public function getUrlParams(?CmsPage $page = null): array
{
$firstCategory = $this->categories->first();
$params = [
'id' => $this->id,
'slug' => $this->slug,
'category' => $firstCategory ? $firstCategory->slug : null,
];
// Expose published year,…

Replies: 9 comments 19 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by 01Kuzma
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@LukeTowers
Comment options

Comment options

You must be logged in to vote
11 replies
@01Kuzma
Comment options

@LukeTowers
Comment options

@01Kuzma
Comment options

@01Kuzma
Comment options

@LukeTowers
Comment options

Comment options

You must be logged in to vote
5 replies
@LukeTowers
Comment options

@01Kuzma
Comment options

@01Kuzma
Comment options

@LukeTowers
Comment options

@01Kuzma
Comment options

Comment options

You must be logged in to vote
2 replies
@LukeTowers
Comment options

@01Kuzma
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants