-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christoph
committed
May 23, 2018
1 parent
48858d9
commit ac71205
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php namespace ProcessWire; | ||
|
||
/** | ||
* Posts template | ||
* Demo template file populated with MarkupBlog output and additional custom code for the Blog Posts | ||
* | ||
*/ | ||
|
||
// CALL THE MODULE - MarkupBlog | ||
$blog = $modules->get("MarkupBlog"); | ||
|
||
// main content | ||
$content = ''; | ||
$content .= "<h2>{$page->get('blog_headline|title')}</h2>"; | ||
//render a limited number of summarised posts | ||
$content .= $blog->renderPosts("limit=5", true); | ||
|
||
// rss | ||
/** Note, for the RSS to work, you should not output anything further after calling this, as it outputs the RSS directly. If not, you will get an error **/ | ||
|
||
// if we want to view the rss of posts | ||
if($input->urlSegment1) { | ||
// rss feed | ||
if($input->urlSegment1 != 'rss') throw new Wire404Exception(); | ||
$homepage = $pages->get('/'); | ||
//render rss; just an example...we have no meta_description field | ||
$blog->renderRSS($page->children("limit=10"), $homepage->get('headline|title'), $homepage->get('summary|meta_description')); | ||
return;// this is important: stops output of any other markup except the RSS xml | ||
} | ||
|
||
|