display all posts under domain/blog/post
Posted: Mon Feb 11, 2019 10:01 pm
Hello
I'm struggling with a problem how to make bludit display blog posts under /blog/ parent. Every approach I tried ended up with more errors to bare with.
I've read all posts about similar question on this forum, and github issues, but all provided solutions aren't working in the way I'd be satisfied.
I'd like to:
1. show last 3 blog posts on homepage
2. show all blog posts with pagination under static page, assuming its slug (uri) is set as 'blog'. Blog posts should be accessible with domain.ext/blog/post1, /blog/post2 and so on
3. leave all other static pages with their default behaviour, without any redirects, filters, just as default top level pages
I base on devtheme, latest B 3.7.1 (github-master), and apache webserver (shared hosting provider)
1. I cannot set /blog/ in settings > advanced > filters, because all pages both static and posts are redirected to domain/blog/slug
This ends up with "404 page not found"
Adding redirects to .htaccess - which was one of users solution - does not change anything, it's a problem with filtering.
I've tried to set a different page as homepage. Things got even worse.
2. I thougt I'll come up with additional template file for a blogroll (list of all blog posts).
I created a new static page with 'blog' in friendly url field, and set a fixed template name 'blogroll' in page's advanced settings
Then I've created an additional template/php/blogroll.php file for this static page, which lists all published posts - it's literally a copy of home.php, just to make things work in a raw way.
In themes/theme/index.php I conditionally load the blogroll.php for page with blogroll in its options, with 'blog' as its uri, and for a static type of page - just to load it only for this one particularly page, and list all posts.
Until this part everything was working.
/blog page loads the blogroll.php template file, but errors gallery starts to appear. I cannot use devtheme's builtin' foreach loop to show , as It only gets the "blog" static page's content. Thus I reworked the loop using method desribed in docs to list all posts:
https://docs.bludit.com/en/dev-snippets/content-pages
Still two problems.
1. setting lower amount of posts to show per page in advanced option, to force pagination doesn't work as supposed. Pagination shows up, but all the posts are being show on all subpages with older entries. I'm unable to come up with a fix for this.
2. this is a minor thing, but I thought about providing a parent page for all posts. Unfortunately static page cannot be set as a parent in page's advanced settings.
I feel that all 3 things I'd want to achieve may somehow be done in easier way.
But my knowledge of php and skills in programming are apparently insufficient to achieve - one could possibly think - such easy thing available out of box in most popular CMSes.
I'm struggling with a problem how to make bludit display blog posts under /blog/ parent. Every approach I tried ended up with more errors to bare with.
I've read all posts about similar question on this forum, and github issues, but all provided solutions aren't working in the way I'd be satisfied.
I'd like to:
1. show last 3 blog posts on homepage
2. show all blog posts with pagination under static page, assuming its slug (uri) is set as 'blog'. Blog posts should be accessible with domain.ext/blog/post1, /blog/post2 and so on
3. leave all other static pages with their default behaviour, without any redirects, filters, just as default top level pages
I base on devtheme, latest B 3.7.1 (github-master), and apache webserver (shared hosting provider)
1. I cannot set /blog/ in settings > advanced > filters, because all pages both static and posts are redirected to domain/blog/slug
This ends up with "404 page not found"
Adding redirects to .htaccess - which was one of users solution - does not change anything, it's a problem with filtering.
I've tried to set a different page as homepage. Things got even worse.
2. I thougt I'll come up with additional template file for a blogroll (list of all blog posts).
I created a new static page with 'blog' in friendly url field, and set a fixed template name 'blogroll' in page's advanced settings
Then I've created an additional template/php/blogroll.php file for this static page, which lists all published posts - it's literally a copy of home.php, just to make things work in a raw way.
In themes/theme/index.php I conditionally load the blogroll.php for page with blogroll in its options, with 'blog' as its uri, and for a static type of page - just to load it only for this one particularly page, and list all posts.
Until this part everything was working.
/blog page loads the blogroll.php template file, but errors gallery starts to appear. I cannot use devtheme's builtin' foreach loop to show , as It only gets the "blog" static page's content. Thus I reworked the loop using method desribed in docs to list all posts:
https://docs.bludit.com/en/dev-snippets/content-pages
Still two problems.
1. setting lower amount of posts to show per page in advanced option, to force pagination doesn't work as supposed. Pagination shows up, but all the posts are being show on all subpages with older entries. I'm unable to come up with a fix for this.
2. this is a minor thing, but I thought about providing a parent page for all posts. Unfortunately static page cannot be set as a parent in page's advanced settings.
I feel that all 3 things I'd want to achieve may somehow be done in easier way.
But my knowledge of php and skills in programming are apparently insufficient to achieve - one could possibly think - such easy thing available out of box in most popular CMSes.