I have used the Demo Custom Blog Setup on my list view and it works great - https://docs.treepl.co/demo-custom-blog. This code won’t work on the detail view layout though. Anyone got a work around to the code to get this working?
Generally it should work with a few minor adjustments… like where we have prepend: this.url
on all the links we’d need to change to the blog listing page url instead (prepend: "/my-blog"
)
And be sure you’re adding the full blog post collection to the detail layout as well:
{% component source: "Blog Post", layout: "", limit: "1000", collectionVariable: "allPosts", type: "module" %}
I’ll tweak the demo blog to include this layout in the detail view as well… stand-by…
That would be great cause I can’t seem to get it to display.
Ok, I’ve adjusted that layout now and looks to be all working.
A few more adjustments needed then I thought
https://docs.treepl.co/demo-custom-blog/sample-post-two
@Adam.Wilson do you have liquid code available to display ‘Recent Posts’ like you do for Tags/Catalogues/Archive?
There’s 2 possible ways;
- In the main blog post component at the top where we are creating the
allPosts
collection, add a sort order (which probably should be there anyway) and then just loop through however many you want to display using thelimit
filter:
{% for r in allPosts.items limit: 10 %}
<li><a href="{{r.url}}">{{r.name}}</a></li>
{% endfor %}
- Just insert a new
Blog Post
component configured for your needs, ie:
{% component source: "Blog Post", layout: "List", filterBy: "parentid", filterValue: "1234", sortBy: "releasedate", sortOrder: "DESC", limit: "10", type: "module" %}
(you may want to create a new list layout for this option)
Yes, add sortBy: "releasedate", sortOrder: "DESC",
to the main Blog Post component at the top that we’re creating the collection from.
Hi Adam, is it possible to display a list of titles of each blog on the side instead of categories?
Hi Mary.
Sure, you’d just output a list of Blogs using this component:
https://docs.treepl.co/component-types/module-blog
and use a custom list layout that only renders the blog name.
Hopefully, I’ve understood your requirements correctly in that you have multiple blogs and want to display a list of those blogs in the sidebar of any other blog you may be viewing?
HI Adam, no sorry I meant blog posts. But I have worked it out now after several hours of staring at your sample code. Thanks for your reply. Now I am trying to show the author’s name on a post layout, but am just getting a number. I wish I didn’t have to hand code everything. It is very hard when you don’t actually know much liquid code. Thanks again for your help.
Ah I have worked it out now. I need to use the tag Author_Name and not Author