Custom page listing only posts from one category

Post Reply
arikenko
Jr. Bludit
Posts: 4
Joined: Sun May 05, 2019 2:49 pm

Sun May 05, 2019 2:56 pm

Hello,
I've used

Code: Select all

if ($WHERE_AM_I == 'page') {
   if ($page->slug() == 'news') {
      include(THEME_DIR_PHP.'news.php');
   } else {
      include(THEME_DIR_PHP.'page.php');
   }
} else {
   include(THEME_DIR_PHP.'home.php');
}
in my index.php and when I open "news" static page it takes the code from news.php

My news.php is basically copied from home.php but I just removed the code for featured posts.

Code: Select all



<!-- Begin Site Title
================================================== -->
<div class="container">
		<div class="mainheading">
	</div>
<!-- End Site Title
================================================== -->

<!-- Begin List Posts
================================================== -->
<section class="recent-posts">
<div class="section-title">
	<h2><span><?php ($WHERE_AM_I=='search'?$language->p('Search'):$language->p('Aktualności')) ?></span></h2>
</div>
<div class="card-columns listrecent">
	<?php if (empty($content)) { $language->p('No pages found'); } ?>
	<?php foreach ($content as $page): ?>
	<!-- begin post -->
	<div class="card">
		<a href="<?php echo $page->permalink(); ?>">
			<div style="background-image:url(<?php echo ($page->coverImage()?$page->coverImage():Theme::src('img/noimage.png')) ?>); background-size: cover; background-position: center; width:100%; height:250px;"></div>
		</a>
		<div class="card-block p-3">
		<div class="metafooter">
				<div class="wrapfooter">
					<span class="author-meta">
					<span class="post-date"><?php echo $page->date(); ?></span><span class="post-read"></span>
				</div>
			</div>
			<h2 class="card-title"><a href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a></h2>
			<h4 class="card-text"><?php echo (empty($page->description())?$language->p('uzupełnił opis aktualności'):$page->description()) ?></h4>
		</div>
	</div>
	<!-- end post -->
	<?php endforeach ?>

</div>
</section>
<!-- End List Posts
================================================== -->

<?php if (Paginator::numberOfPages()>1): ?>
<nav aria-label="Page navigation example">
	<ul class="pagination justify-content-center">
		<?php if (Paginator::showPrev()): ?>
		<li class="page-item"><a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1">&#9664; <?php $language->p('Previous page') ?></a></li>
		<?php endif ?>

		<?php if (Paginator::showNext()): ?>
		<li class="page-item"><a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php $language->p('Next page') ?> &#9658;</a></li>
		<?php endif ?>
	</ul>
</nav>
<?php endif ?>

<!-- Begin Footer
================================================== -->
<div class="footer">
	<p class="pull-left">
		<?php echo $site->footer(); ?>
	</p>
	<p class="pull-right">
		Zachodniopomorskie Centrum Kształcenia Zawodowego i Ustawicznego w Szczecinie |
		made by <a target="_blank" href="">Ganbaru</a>
	</p>
	<div class="clearfix">
	</div>
</div>
<!-- End Footer
================================================== -->

</div>
<!-- /.container -->

the problem is that it's only listing itself. It can't see other $content pages

Here are the links
homepage url http://zckziu.pl/nowa
news url http://zckziu.pl/nowa/news

any idea how to make it work ?
or another way to create a custom page to list posts just from one category ?

Thanks
Ari :-)
User avatar
Edi
Site Admin
Posts: 1593
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Mon May 06, 2019 3:01 pm

arikenko wrote:
Sun May 05, 2019 2:56 pm
the problem is that it's only listing itself. It can't see other $content pages
The logic is that a "page" shows one page or one post.
or another way to create a custom page to list posts just from one category ?
You can use a link like

https://mydomain.com/category/mycategory
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Jay
Master Bludit
Posts: 69
Joined: Mon Feb 11, 2019 8:41 pm

Mon May 06, 2019 6:38 pm

Check snippets in docs https://docs.bludit.com/en/dev-snippets/content-pages

You need to get the list of pages from DB firstly, as $content contains only your static page content
arikenko
Jr. Bludit
Posts: 4
Joined: Sun May 05, 2019 2:49 pm

Wed May 08, 2019 11:45 pm

How can I edit the category / tag page ?
It seems it's using the home.php and I need a different page for category A and different for category B

The idea is to add some text about the category and below it the cards of each post/page from that category would be visible.

Any ideas ?

Cheers
Ari :-)
User avatar
Edi
Site Admin
Posts: 1593
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Thu May 09, 2019 12:34 am

arikenko wrote:
Wed May 08, 2019 11:45 pm
How can I edit the category / tag page ?
You can use the following code snippet:

Code: Select all

<?php echo Theme::metaTags('description'); ?>
This shows the content of the description field of a category.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
Post Reply