-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog-post - Copy.php
61 lines (46 loc) · 2.92 KB
/
blog-post - Copy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php namespace ProcessWire;
/**
* Post template
* Demo template file populated with MarkupBlog output and additional custom code for a Blog Post
*
*/
// CALL THE MODULE - MarkupBlog
$blog = $modules->get("MarkupBlog");
// subnav
$subNav = '';
// subnav: get date info for creating link to archives page in subnav
$date = $page->getUnformatted('blog_date');
$year = date('Y', $date);
$month = date('n', $date);
// subnav: if there are categories and/or tags, then make a separate nav for them
if(count($page->blog_categories)) $subNav .= $blog->renderNav(__('Related Categories'), $page->blog_categories);
if(count($page->blog_tags)) $subNav .= $blog->renderNav(__('Related Tags'), $page->blog_tags);
// subnav: contains authors, archives and categories links
$authorsURL = $pages->get('template=blog-authors')->url;
$archivesURL = $pages->get('template=blog-archives')->url;
// use pageName sanitized author title as PART of URL, else empty
$authorURL = $sanitizer->pageName($page->createdUser->title) ? $sanitizer->pageName($page->createdUser->title) . '/' : '';
$authorName = $page->createdUser->title ? $page->createdUser->title : 'Author Name';//use generic 'Author Name' if author title not yet set
$subNavItems = array(
$authorsURL . $authorURL => $authorName,
$archivesURL . $year . "/" . $month . "/" => strftime('%B %Y', $date)
);
$subNav .= $blog->renderNav(__('See Also'), $subNavItems);
// main content
// render a single full post including title, comments, comment form + next/prev posts links, etc
// $blog->postAuthor(): if available, add 'post author widget' at the end (or at the top if desired) of each post
// $content = $blog->renderPosts($page) . $blog->renderComments($page->blog_comments) . $blog->renderNextPrevPosts($page);//without post author
/*
for this demo, renderComments() has to adapt to whether blog commenting feature was installed or not whilst remaining blog structure/style-agnostic
in your own blog install, you would know if you enabled the feature so there would be no need for such a check
in addition, our 'check' code is not code you would normally use in a template file.
we use such code here to be both foolproof that the commenting feature is installed and blog structure-agnostic
*/
#not foolproof; user could have post-installed custom commenting feature (e.g. Disqus) with a similar field blog_comments
// $renderComments = $page->template->hasField('blog_comments') ? $blog->renderComments($page->blog_comments) : '';
$blogConfigs = $modules->getModuleConfigData('ProcessBlog');
$renderComments = $blogConfigs['commentsUse'] == 1 ? $blog->renderComments($page->blog_comments) : '';
// with post author widget
$content = $blog->renderPosts($page) . $blog->postAuthor() . $renderComments . $blog->renderNextPrevPosts($page);
// include the main/common markup
require_once("blog-main.inc");