rainlab / pages-plugin

Adds static pages and menus
MIT License
122 stars 99 forks source link

Blog category page not displayed #436

Closed PrestaSafe closed 4 years ago

PrestaSafe commented 4 years ago

Description:

When i choose All blog categories, the only page is selected it's called Blog. So my category page detail is named: category-blog The component Category List is present in that page too.

The URL generated is not the good one and the same /blog for all of categories.

Capture d’écran 2020-04-01 à 22 49 45 Capture d’écran 2020-04-01 à 22 44 56

Thanks.

LukeTowers commented 4 years ago

Please post the file contents of the page that is showing up and the one that isn't so we can compare.

PrestaSafe commented 4 years ago

page displayed: blog.htm

title = "Blog"
url = "/blog/:page?"
layout = "default"
meta_title = "Blog développement web Laravel et PrestaShop"
meta_description = "Découvrez nos articles conernant le développement web sur Laravel PrestShop et October CMS"
is_hidden = 0
robot_index = "index"
robot_follow = "follow"

[blogPosts]
pageNumber = "{{ :page }}"
categoryFilter = "{{ :slug }}"
postsPerPage = 12
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "category-blog"
postPage = "post-details"

[searchForm]
resultPage = "search"
categoryFilter = 0

[blogCategories]
slug = "{{ :slug }}"
displayEmpty = 1
categoryPage = "category-blog"
==
<section class="breadcrumb_area">
    <div class="container">
        <div class="breadcrumb_content text-center">

         <div class="row">
                <div class="col-md-12">
                   <h1 class="f_p f_700 f_size_50 w_color l_height50 mb_20">Blog</h1>
                    <div class="text-center">
                        <img class="img-fluid" src="{{ 'assets/img/prestasafe/undraw_blooming_jtv6.svg'|theme }}"
                            alt="Blog développement web et agence web">
                    </div>
                    <p class="f_400 w_color f_size_16 l_height26">Découvrez tous mes articles, écrit avec amour </p>
                </div>
            </div>
        </div>        
    </div>
</section>

  <section class="blog_area sec_pad">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8">
                        <div class="row">
                            {% component 'blogPosts' %}                          
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="blog-sidebar">
                            <div class="widget sidebar_widget widget_search">
                                {% component 'searchForm' %}
                            </div>
                            {% component 'blogCategories' %}

                        </div>
                    </div>

                </div>
            </div>
        </section>

Page not displayed category-blog.htm

title = "category-blog"
url = "/category/:slug/:page?"
layout = "default"
meta_title = "category-blog"
meta_description = "category-blog"
is_hidden = 0
robot_index = "index"
robot_follow = "follow"

[blogPosts]
pageNumber = "{{ :page }}"
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "category-blog"
postPage = "post-details"

[blogCategories]
slug = "{{ :slug }}"
displayEmpty = 0
categoryPage = "category-blog"

[searchForm]
resultPage = "search"
categoryFilter = 0
==
<?php
function onEnd()
{
    //dd($this);
    $this->page->meta_title = "Catégorie ".$this->param('slug'); 
    $this->page->meta_description = "Article de blog de la catégorie ".$this->param('slug'); 
}
?>
==
<section class="breadcrumb_area">
    <div class="container">
        <div class="breadcrumb_content text-center">

         <div class="row">
                <div class="col-md-12">
                   <h1 class="f_p f_700 f_size_50 w_color l_height50 mb_20">Catégorie {{ this.param.slug }} </h1>
                    <div class="text-center">
                        <img class="img-fluid" src="{{ 'assets/img/prestasafe/undraw_blooming_jtv6.svg'|theme }}"
                            alt="Blog développement web et agence web">
                    </div>
                    {#<p class="f_400 w_color f_size_16 l_height26">Découvrez tous mes articles, écrit avec amour </p>{##}#}
                </div>
            </div>
        </div>        
    </div>
</section>

  <section class="blog_area sec_pad">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8">
                        <div class="row">
                            {% component 'blogPosts' %}                          
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="blog-sidebar">
                            <div class="widget sidebar_widget widget_search">
                                {% component 'searchForm' %}
                            </div>
                            {% component 'blogCategories' %}

                        </div>
                    </div>

                </div>
            </div>
        </section>

Thanks to you !

LukeTowers commented 4 years ago

The issue is that blogPosts on your category page must include a category filter: https://github.com/rainlab/blog-plugin/blob/master/models/Category.php#L144-L147.

Change it to

[blogPosts]
categoryFilter = "{{ :slug }}"
pageNumber = "{{ :page }}"
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "category-blog"
postPage = "post-details"
PrestaSafe commented 4 years ago

@LukeTowers Thanks it works fine now !