Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello!

I have created a sidebar snippet, that is embeded on my "blog.php" page.
"blog.php" page contains a list of the articles from the blog.

The articles template clonable pages are in another page called "article.php".

So in my "blog.php" page, I use the following to display them :

Code: Select all
          <cms:pages masterpage='article.php'
                folder=k_folder_name
                start_on=k_archive_date
                stop_before=k_next_archive_date
                paginate='1'
                limit='3' >

                <a href="<cms:show k_page_link />"><div class="blog-post-preview-img" style="background-size:cover;background-image:url('<cms:show blog_image />')"></div></a>
                <div class="blog-post-preview">
                  <h2 class="h2-blog-post-title-preview"><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></h2>

                  <div class="blog-post-preview-author">Published <cms:date k_page_date format='j/m/y'/>&nbsp;par&nbsp;<cms:show author /></div>
                  <p><cms:excerptHTML count='75' ignore='img'><cms:show blog_content /></cms:excerptHTML></p>
                  <a href="<cms:show k_page_link />" class="w-button line-button">Read more</a>
                </div>
        <cms:paginator />
          </cms:pages >


Everything works great for that part.
For the sidebar with the categories (folders) available for the articles, I've create a "blog-sidebar.php" file, containing the following code :

Code: Select all
<cms:folders masterpage='article.php'>
<div class="sidebar-category">
  <a href="<cms:show k_folder_link />"><p class="w-clearfix sidebar-list-item"><cms:show k_folder_title /><span class="number-end-row">(<cms:show k_folder_totalpagecount />)</span>
  </p></a>
</div>
</cms:folders>


It does display a list of all the categories, wich is perfect, and also the number of articles that has the same category with k_folder_totalpagecount...but when I click on a category, it sends me to the blank "article.php" page template.

I need the "blog.php" page (the one that lists the articles), to change its content to display the articles linked with the category you have clicked on.

Like most blog works.

What am I doing wrong?

Thanks!
Hi :)

k_folder_link is inside cms:folders which fetches data from 'articles' and doesn't 'know' about blog.php. That's why to redirect users from the 'blog' template again to 'blog' template and show different subset of pages, you have to find the way how to change parameters in cms:pages. It would be much easier to have articles stored in blog.php and using folders and links from blog on blog, in this case no need to indicate masterpage for both cms:pages and cms:folders, and links would work.

In your current situation you may try the following. Change folder=k_folder_name to
Code: Select all

<cms:pages masterpage='article.php'
                folder="<cms:gpc 'cat' />"



and place this instead of k_folder_link:
Code: Select all

<a href="<cms:add_querystring "<cms:link masterpage='blog.php' />" "cat=<cms:show k_folder_name/>" />" >



It will construct a URL like blog.php?cat=some-folder-name
This link will redirect users on the same blog and <cms:gpc> will read name of folder from querystring in URL and instruct cms:pages to show articles from indicated folder. If someone visits blog.php without querystring, cms:pages will keep showing the same articles like it does now, because empty value folder="" will be ignored. (folder=k_folder_name is also ignored in your current setup, because k_folder_name is always empty)

Please let me know if it works.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi Anton!

Thanks a lot. It's working perfectly.
I understand now why it was not working.

Thanks a bunch again!
3 posts Page 1 of 1