Jump to content

Module: Blog


Recommended Posts

Thanks for the info kongondo :)

For anyone wanting a 'quick hack for now' for setting the published date, run through the MarkupBlog.module file, and the template files and find:


and immediately after add this:

, blog_date<=".date('Y-m-d G:i:s')."

This will basically add a condition to the post (aka page) lookup, to make sure the date field is set to now, or lower. I've run some tests on my local copy and it's working as expected.

Link to comment
Share on other sites

Scheduled publishing is an integral part of the workflow for many bloggers, so this would definitely make sense. I couldn't live without such a feature anymore.. :)

@kongondo: if you're still pondering whether to use SchedulePages somehow or cook up your own method, I'd vote for SchedulePages. Admittedly I'm being somewhat selfish here (I'm sure we'll be using this module for our client sites and I don't like the idea of having to explain why and how scheduling posts is different from all other pages) but it's also a great module :)

I haven't made a decision on this yet. On the one hand I don't want to reinvent the wheel; why not just use SchedulePages. On the other, I am a bit wary of tying an important functionality of Blog to a third party module that is not part of the core. In case things were to break in the future and they were not fixed (no offence meant to Jasper), that would leave Blog users hanging.....Maybe I am being over cautious. I'll make a decision soon...

Sorry for spamming (sort of), but just wanted to comment on this one that most (quite possibly all) of the sites we've implemented a blog for have more than one blog. Doesn't sound that far fetched to me: one or more for internal use, one for each division (a lot of our blogging clients are municipalities and they've got a ton of these), one for CEO/mayor, one for each temporary project etc.

Also, if you were referring to creating a bunch of user-specific blogs: I've explained this sort of behaviour (in another system) to clients over and over and over and can assure you that, though it may sound like the logical solution, in real world it just doesn't work.. unless you also allow some sort of "blog superusers" to post with any user account, which could introduce an entire set of new problems :)

One typical situation is a CEO or mayor having his/her own blog. Most people of that caliber simply don't have much spare time and blogging is rarely considered a core task, so even if this person does really write his/her own posts, there's a very high probability that someone else handles posting them online.. which is where the trouble starts if each blog is tied to one user. I'm sure you get the point.

Anyway, I'd appreciate if you could consider this kind of feature, but I get that it's probably not too high in priority :)

Admittedly I currently have no idea how I could implement such a feature and to be honest, I haven't thought much about it. Where would the posts, tags and categories  live on the tree for the different blogs? It could get messy very quickly. Anyway, any and all ideas are welcome, thanks! 

Link to comment
Share on other sites

On the one hand I don't want to reinvent the wheel; why not just use SchedulePages. On the other, I am a bit wary of tying an important functionality of Blog to a third party module that is not part of the core. In case things were to break in the future and they were not fixed (no offence meant to Jasper), that would leave Blog users hanging.....Maybe I am being over cautious.

Nothing wrong with being careful, but luckily we're talking about free software here. If it's any more reassurance, we've got a lot of sites relying on this module already, so trust me: in the (unlikely) scenario that something was to happen and the module wasn't kept up to date, I for one would be more than happy (and forced, actually..) to catch the ball ;)

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

This post is in response to this question posted on GitHub

Comment Layout

I'm using Foundation instead of Skeleton and need to tweak some of the layout.
Can you identify which file I would need to tweak to change the comments layout? I can do so much via CSS but not the bigger shifting around of content

First, I'd like to reiterate that this Blog Module does not use any CSS framework. The Blog (site) Profile (on which Blog Module is based) uses the Skeleton CSS framework. However, in this Module's demo/example output/template files, I have used PocketGrid CSS. It is not a requirement. You can use whichever CSS framework (or not) you wish. The following example is for this module (but is equally applicable to the Blog Profile).

It is very easy to style Blog's comments by targeting the output HTML IDs and Classes in your CSS. In my example template files, my custom styles are in blog.css. The example code below is an HTML output of Comments where 'comments are allowed'.

<div id="comments">
	<span class="num-comments-icon">2</span>
	<ul class="comments CommentList">
		<li class="comment CommentListItem" id="comment1">
			<p class="comment-head CommentHeader">Comment by kongondo on 13 April 2014 11:16 pm</p>
			<div class="comment-body CommentText"><p>Simply the best CMS.</p></div>

		<li class="comment CommentListItem" id="comment10">
			<p class="comment-head CommentHeader">Comment by kongondo on 23 May 2014 2:42 pm</p>
			<div class="comment-body CommentText"><p>ProcessWire rocks, yeah!</p></div>

	<div id="CommentForm" class="CommentForm_new">
		<h4>Post a comment</h4>
		<form id="CommentForm_form" action="./#CommentForm" method="post">
			<p class="CommentForm_cite">
				<label for="CommentForm_cite">Your Name</label>
				<input type="text" name="cite" class="required" required="required" id="CommentForm_cite" value="" maxlength="128">
			<p class="CommentForm_email">
				<label for="CommentForm_email">Your E-Mail</label>
				<input type="text" name="email" class="required email" required="required" id="CommentForm_email" value="" maxlength="255">
			<p class="CommentForm_text">
				<label for="CommentForm_text">Comments</label>
				<textarea name="text" class="required" required="required" id="CommentForm_text" rows="5" cols="50"></textarea>
			<p class="CommentForm_submit">
				<button type="submit" name="CommentForm_submit" id="CommentForm_submit" value="1">Submit</button>
				<input type="hidden" name="page_id" value="2488">

So, you do not need to tweak any file. All you need is to style the output.

For the PHP stuff, I am in the process of writing some documentation...

Hope this answers your query. Thank you for using Blog :-)

  • Like 4
Link to comment
Share on other sites

Cheers for the reply and apologies re the framework mixup.

I guess I'm approaching this with a few expectations picked up from my other blogging platform. Within that, almost every part of the blog was a mini template which you could tweak to make fundamental layout changes.

Link to comment
Share on other sites

Sparrow, no need to apologise for anything :-). Your question will help the next guy. Once I write the API documentation, you'll realise that you can also tweak this Blog to make fundamental layout changes. You can output bits and pieces (tags, posts, categories, authors, comments, etc) anywhere using its API since it is a PW module. All these bits and pieces are independent of each other. This is similar to PW pages in the sense that you can output page fields anywhere in any order in your site or even not output any of the fields.

  • Like 2
Link to comment
Share on other sites


Minor version bump to 1.2.1 after some minor styling issues updates.


I am taking a short break from writing code to write some badly needed documentation for Blog (and some other PW tutorials if I get time :-)). I am writing this documentation as tutorials which I will post on my website soon. I'll keep you updated. I haven't forgotten any Blog features pending requests :-)

  • Like 4
Link to comment
Share on other sites

Thank you Kongondo and Ryan for these excellent modules!

I've implemented this into a site I'm developing and am having an issue... The blog posts are not truncating. I have the summary length set to 150 , but nothing is being truncated. I know when i created a post I'm populating the "blog_body" field and these settings seem to be for the "blog_summary" field (which does is not one of the fields for the template).. From what I can see in the MarkupBlog.module, there is a conditional if summary is empty to pull from the blog_body and truncate.

The blog I'm working on is here: http://shootkta.info/blog/ .. If you have any thoughts, please let me know.

  • Like 1
Link to comment
Share on other sites

Hi Webweaver,

Glad you like the module.

It is truncating fine for me here. The code is pulling text to truncate from blog_body. I decided to skip over using a blog_summary since truncation can be done from blog_body. I am guessing it is not truncating because you have not set the second parameter/argument of renderPosts() to true. The default is false (i.e. do not truncate). Apologies for this; I have delayed with documentation but I am currently writing this. Here's example code to make it truncate.

$blog = $modules->get("MarkupBlog");
$limit = 10;
//limit will be passed to the selector fetching blog posts;
//'true' will truncate posts to what we have set in blog_quantity but default to 450 if this is not set
$content = $blog->renderPosts("limit={$limit}", true);
echo $content;
  • Like 1
Link to comment
Share on other sites

@Kongondo - Thank you very much for the explanation to fix. Next time I'll know not to pull my hair out for 2 hours and just ask the question and wait for the reply :)

Btw, the generated summary strips out all tags so the posts in the blog list looked pretty bad.. So I removed the strip tags.. But then had another problem - if the cutoff was in the middle of an anchor tag, the "view more" anchor tag would become nested and didn't work.. So I put back in the strip tags but allowed <p> and <img> tags.. The summaries in the blog list look much nicer now.

ex: Line 543 in MarkupBlog.module now reads:

$summary = strip_tags(substr($page->blog_body, 0, $summaryLimit), '<p><img>');
Link to comment
Share on other sites

As for <p></p>, those are added back later. See line 602 of the code

if($small) {

  $out .= "<p>" . $page->summary . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>";

Hadn't considered images in the summary.... :-)..Maybe I'll need to add at blog_summary [non-rich text area] to the blog template.


Or, for now, maybe not. I don't want to add too many fields...I'll have a think

Edit 2:

We now have this feature inbuilt in renderPosts(). You can specify tags that should not be stripped as indicated in this post:

https://processwire.com/talk/topic/7403-module-blog/?p=78227 (see  post_small_allowable_tags)

Edited by kongondo
Link to comment
Share on other sites

Ya, I hesitated on the img tag :) Basicly I want them to see a majority of the post in full formatting (as much as possible) while they are on the blog listing page.

But line 602 is surrounding the entire post in a paragraph, so there is still no formatting within it. The paragraphs within the post itself were getting stripped.

I should mention also that I enabled CKEditor in for the blog_body field and changed the code in ProcessBlog.module for quickpost_body to use CKEditor also (line 387), but the tags were being stripped from the quickpost CKEditor, so had removed the sanitizer from quickpost (line 1441).

Link to comment
Share on other sites

Forgot to ask, if I install a fresh processwire 2.4 and the 2 blog modules,

how does the blog show up on the front ? I mean a fresh pw 2.4 install

has it´s own default front with nav, body and sidebar. How does the blog

integrate with this ?


Got it, installing and just saw the blog template files, css and js.

It is really complete !

How can I disable the default front that came during the processwire install

and only have the basic blog front ?

uploaded all the php blog files to /site/templates/

and in admin tried to change template for home to blog.php

but didn´t allow me.

Ok dumb me, just had to delete home.php and rename blog.php to home.php

Now I can start building up :) it´s using pocketgrid so that is a real bonus.

In the admin I saw a new tab named Blog will all the great config in it.


Link to comment
Share on other sites

Guys, apologies for not responding earlier.


I've had a thought about the 'summary' text and I want to leave it as is for now. My reckoning is that a summary is just that; a blurb of text (usually one paragraph)...

Thanks for reporting the issue with sorting the 'date' field. The Posts Table is being generated from ProcessWire (MarkupAdminDataTable). So, this is not an issue with ProcessBlog per se but thanks for catching that. I have actually been considering using other tables (e.g. DataTable) that are capable of dynamic sorting (i.e. sorting from the database). The sorting your see now is static and does not draw from the database. 

As for quickpost I have been wavering between making it RTE or not. I reckoned that many people would not be using it often for post creation. If there's sufficient demand I might change it back to RTE.


Glad you find the module useful. As stated in the first post, I intentionally used lots of template files in an attempt to make it easier for folks to see what's going on in the code. It is definitely not the recommended templating approach. In addition, using the Blog API, the user would be able to use the templating approach they wanted (as well as the CSS framework they wanted). However, documentation to assist users with the API is badly needed (and I am working on this at the moment). So in time, you will be able to 'disable the default front' that comes with MarkupBlog. This means basically deleting the template files :-). Technically, Blog does not need any of those template files. They are just there to showcase its capabilities. 

OK, back to writing.... :-)

Link to comment
Share on other sites

@kongondo: sorry if this is unrelated (I don't have a proper test environment at hand right now) but sorting by dates is entirely doable using MarkupAdminDataTable too. It just requires a bit of extra work: prefixing actual, visible value with hidden, sortable value; something like yyyy-mm-dd etc.

This is how I solved it in ProcessLoginHistory.

Sorting multi-page values is another issue entirely, but as far as sorting visible results is good enough, no need to complicate things with new 3rd party components :)

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...