$superuserRole = $roles->get('superuser'); $authors = $users->find("roles={$authorRole}|{$superuserRole}, sort=title"); $authorLinks = array(); foreach ($authors as $a) { // we set a separate URL (url2) to reflect the public url of the author, since // the author's $author->url is actually a page in the admin $a->url2 = $page->url . $a->name . '/'; $authorLinks[$a->url2] = $a->get('title|name'); } if ($input->urlSegment1) { // author specified: display biography and posts by this author $name = $sanitizer->pageName($input->urlSegment1); $author = $users->get($name); if (!$author->id || !$author->hasRole($authorRole) && !$author->isSuperuser()) { throw new Wire404Exception(); } $posts = $pages->find("template=post, created_users_id={$author}, sort=-date, limit=10"); $authorName = $author->get('title|name'); $t = new TemplateFile($config->paths->templates . "markup/author.php"); $t->set('authorName', $authorName); $t->set('authorURL', ''); $t->set('author', $author); $headline = $page->title; $content = $t->render() . renderPosts($posts, true); $subnav = renderNav($page->title, $authorLinks, $page->url . $author->name . '/'); } else { // no author specified: display list of authors $headline = $page->title; $content = $page->body . renderAuthors($authors); } include "./main.inc";
<?php /** * Home template * */ include_once "./blog.inc"; $categories = $pages->get('/categories/'); $content = $page->body . renderPosts("limit={$page->quantity}"); $subnav = renderNav($categories->title, $categories->children); include "./main.inc";
<?php /** * Category template * */ include_once "./blog.inc"; $posts = $pages->find("template=post, categories={$page}, limit=10"); if ($input->urlSegment1) { // rss feed if ($input->urlSegment1 != 'rss') { throw new Wire404Exception(); } renderRSS($posts); return; } $n = $posts->getTotal(); $headline = $page->title; $content = $page->body . renderPosts($posts, true); $subnav = renderNav($page->parent->title, $page->siblings, $page); include "./main.inc";
return $out; } /*******************************************************************/ include_once "./blog.inc"; if ($input->urlSegment1 && $input->urlSegment2) { // year and month $year = (int) $input->urlSegment1; $month = (int) $input->urlSegment2; $firstDate = strtotime("{$year}-{$month}-01"); $lastDate = strtotime("+1 month", $firstDate); $selector = "template=post, date>={$firstDate}, date<{$lastDate}, sort=-date"; $posts = $pages->find($selector); $headline = strftime("%B %Y", $firstDate); $content = '<section class="recipes-list"> <div class="container">'; $content .= renderPosts($posts, true); $content .= '</div> </section>'; $archives = getArchives(); $yearsNav = array(); $monthsNav = array(); foreach ($archives as $y) { $yearsNav[$y['url']] = $y['name']; if ($y['name'] == $year) { foreach ($y['months'] as $m) { $monthsNav[$m['url']] = $m['name']; } } } $subnav = renderNav($page->title, $yearsNav, $page->url . "{$year}/") . renderNav($year, $monthsNav, $page->url . "{$year}/{$month}/"); } else {
$date = $page->getUnformatted('date'); $nextPost = $page->parent->child("date>{$date}, sort=date"); $prevPost = $page->parent->child("date<{$date}, sort=-date"); $out = "<section class='next-prev'><div class='next-prev-posts container'><div class='small-12 columns'>"; if ($prevPost->id > 0) { $out .= "<p class='prev-post left text-left'><span class='font-bold uppercase'>Previous Recipe</span><br><a href='{$prevPost->url}'>{$prevPost->title}</a></p>"; } if ($nextPost->id > 0) { $out .= "<p class='next-post right text-right'><span class='font-bold uppercase'>Next Recipe</span><br><a href='{$nextPost->url}'>{$nextPost->title}</a></p>"; } $out .= "</div></div></div></section>"; return $out; } // render our blog post and comments // $content = renderPosts($page) . renderComments($page->comments) . renderNextPrevPosts($page); $content = renderPosts($page) . renderNextPrevPosts($page); // get date info for creating link to archives page in subnav $date = $page->getUnformatted('date'); $year = date('Y', $date); $month = date('n', $date); // if there are categories and/or tags, then make a separate nav for them if (count($page->categories)) { $subnav .= renderNav(__('Related Categories'), $page->categories); } if (count($page->tags)) { $subnav .= renderNav(__('Related Tags'), $page->tags); } // subnav contains authors, archives and categories links $subnavItems = array("{$config->urls->root}authors/{$page->createdUser->name}/" => $page->createdUser->get('title|name'), "{$config->urls->root}archives/{$year}/{$month}/" => strftime('%B %Y', $date)); $subnav .= renderNav(__('See Also'), $subnavItems); include "./_post.inc";
<?php /** * Blog posts template * */ include_once "./blog.inc"; if ($input->urlSegment1) { // check for rss feed if ($input->urlSegment1 != 'rss') { throw new Wire404Exception(); } $homepage = $pages->get('/'); renderRSS($page->children("limit=10"), $homepage->get('headline|title'), $homepage->get('summary|meta_description')); } else { // display paginated blog list $headline = $page->get('headline|title'); $content = renderPosts("limit=10", true); include "./main.inc"; }
<?php /** * Home template * */ include_once "./blog.inc"; $categories = $pages->get('/categories/'); $content = '<section class="recipes-list">'; $content .= renderPosts("limit={$page->quantity}", $small = true); $content .= '</section>'; $subnav = renderNav($categories->title, $categories->children); include "./main.inc";
{ $date = $page->getUnformatted('date'); $nextPost = $page->parent->child("date>{$date}, sort=date"); $prevPost = $page->parent->child("date<{$date}, sort=-date"); $out = "<div class='next-prev-posts'>"; if ($prevPost->id > 0) { $out .= "<p class='prev-post'><span><</span> <a href='{$prevPost->url}'>{$prevPost->title}</a></p>"; } if ($nextPost->id > 0) { $out .= "<p class='next-post'><a href='{$nextPost->url}'>{$nextPost->title}</a> <span>></span></p>"; } $out .= "</div>"; return $out; } // render our blog post and comments $content = renderPosts($page) . renderComments($page->comments) . renderNextPrevPosts($page); // get date info for creating link to archives page in subnav $date = $page->getUnformatted('date'); $year = date('Y', $date); $month = date('n', $date); // if there are categories and/or tags, then make a separate nav for them if (count($page->categories)) { $subnav .= renderNav(__('Related Categories'), $page->categories); } if (count($page->tags)) { $subnav .= renderNav(__('Related Tags'), $page->tags); } // subnav contains authors, archives and categories links $subnavItems = array("{$config->urls->root}authors/{$page->createdUser->name}/" => $page->createdUser->get('title|name'), "{$config->urls->root}archives/{$year}/{$month}/" => strftime('%B %Y', $date)); $subnav .= renderNav(__('See Also'), $subnavItems); include "./main.inc";