ProcessWire - Blog

Aus Wikizone
Wechseln zu: Navigation, Suche

Wie erstellt man einen Blog oder News-Section in ProcessWire ?

Beispiel (Anlehnung an Ryans Blog Beispiel)

blog.php

<?php namespace ProcessWire;
// v1.0
// This is the template file for main /blog/ page that lists blog post summaries.
// If there are more than 10 posts, it also paginates them.
include("./partials/layout-blocks.inc");
$layoutBlocks = renderLayoutBlocks($page,$additionalHeaderData);

$pagerOptions = array(
	 'listMarkup' => "<ul class='uk-pagination'>{out}</ul>",
);
?>

<main id='main' class='uk-container uk-margin uk-margin-large-bottom'>
	<div class='uk-grid-large' uk-grid>
		
		<div id='content' class='uk-width-expand'>
			<?php
			echo ukHeading1(page()->title, 'divider');
			$posts = page()->children('limit=8,sort=-date');
			$pagination = $posts->renderPager($pagerOptions);
			echo($pagination);
			echo ukBlogPosts($posts);
			?>
		</div>

		<aside id='sidebar'  class='uk-width-1-3@m'>
			<?php
			$categories = pages()->get('/categories/');
			echo '<div class="uk-card uk-card-muted uk-card-hover uk-card-body uk-margin-medium-top">'.ukNav($categories->children, [ 'header' => $categories->title ]).'</div>';
			?>
		</aside>

	</div>
</main>