ProcessWire - Blog: Unterschied zwischen den Versionen
Aus Wikizone
(Die Seite wurde neu angelegt: „Wie erstellt man einen Blog oder News-Section in ProcessWire ? == Strategien == === Strategie I - News mit einfachem Page Tree === Einfacher Aufbau mit Index…“) |
Steff (Diskussion | Beiträge) |
||
| Zeile 1: | Zeile 1: | ||
Wie erstellt man einen Blog oder News-Section in ProcessWire ? | Wie erstellt man einen Blog oder News-Section in ProcessWire ? | ||
| − | == | + | == Beispiel (Anlehnung an Ryans Blog Beispiel) == |
| + | blog.php | ||
| + | <syntaxhighlight lang="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> | ||
| + | </syntaxhighlight> | ||
Version vom 5. Dezember 2018, 18:25 Uhr
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>