Jump to content

Module: Blog


kongondo

Recommended Posts

Update: Blog version 1.2

Read below before updating.

For new installs, proceed as normal

-------------------------------------

Changelog

TL:DR: Comments visibility settings + Posts' Bulk Actions + Update Script

Comments

Comments visibility can be controlled 'globally' as well as on a 'per post' basis

Default is that comments and comment form are visible. You do not need to specify this setting; it just applies

A post's comments SPECIFIED visibility overrides the global setting except for one case (see below).

Post Comments Settings are set via a page select on a Post's page (also in 'Settings' tab in Blog Dashboard - see below)

  • No selection: Default [comments and comments form will be shown]
  • Always Show Comments: This will enforce overriding of global setting (e.g. Disable Comments) 
  • Disable New Comments: Will show old comments but not the comments form; visitors will not be able to submit new comments & message 'Comments closed for this post' will be shown.
  • Disable Comments: Will neither show old comments nor the comments form; visitors will not be able to submit new comments & will see message 'Comments not allowed for this post'. Old comments WILL NOT be deleted :D.

Global Comments Settings are set via a page select on the Comments page (in Dashboard as well). Settings here DO NOT override a Post's Comments settings WHERE A SELECTION has been made (i.e. if NOT empty).

  • No selection: Default [comments and comments form will be shown]
  • Disable New Comments: Similar to above Post setting except will affect all Posts' comments where no comments visibility selection has been made. 
  • Disable Comments: Similar to above Post setting except will affect all Posts' comments where no comments visibility selection has been made. 

Global Maximum comments allowed per post.

If any number > 0 is specified in this new setting, IRRESPECTIVE of a Post's comments settings, if a post's comments is greater than the maximum set here, then 'Disable New Comments' will kick in. So, this takes precedence.

Note: If you are logged in as superuser, even PENDING and SPAM comments are counted; so, the Global Maximum may be 'temporarily reached', if that makes sense :-)

Recap of comments visibility, in order of descending priority:

1. Global Maximum comments allowed for posts (/blog/comments/)

2. Any comment visibility SPECIFIED on a post (i.e. not empty) (/blog/posts/your-post/)

3. Any Global comment visibility SPECIFIED on comments page (/blog/comments/)

4. Default.

'Settings' Tab

You can also set both the Global comments visibility and the Global Maximum comments allowed per post on this tab. The current setting will always be selected in the input field.

Note: A blank Global comments visibility means no setting specified :-). So, if you want to change to 'no global setting specified', just select a blank and save [equivalent to deselecting a page select] (hope this makes sense).

Note: Where no Global Maximum comments is set (i.e. blank), saving in the 'Settings' Tab's General Settings will subsequently show a '0' [zero]. This is equivalent to a blank, so not to worry :D

Bulk Actions

Introducing Bulk Actions for the Posts Tab! Make bulk changes to posts:

  • Unpublish/Publish
  • Comments visibility (as specified above for Posts' Comments visibility). In this case, also a 'Default Comments View' selection available. This is the equivalent of the 'no selection' specified in page selection field above.
  • Trash
  • Delete (note: no warning given before delete; careful with this one!)

New column in Posts' Table also shows currently specified Comments visibility for each post. 'Default' means no selection made.

Other

- Some code clean-up.

- See blog-side-bar.inc issue below.

UPDATING

I have written an update script (attached) that will add the new features in Blog 1.2 (2 fields, 1 template, 3 pages, 2 page updates, etc.).

I have thoroughly tested the script. However, try this first on a test/non-essential install! If everything works, you can use it on your live environment

Note: This assumes you haven't changed the native Blog paths and page names. Otherwise, it won't work properly. It won't corrupt any data but may just not install some stuff :D

Note: You will still need to update the module as normal in your PW admin! Above is just to save you manually creating the extra fields, etc.

To update:

# Copy and paste the contents of blog-upgrade-version1-2.txt at the very top of one of your template files. Save the template file.

# The script will only run if you are logged in as a superuser so other users won't know what's happening.

# View a page using the template file you've just amended. The new fields, template and pages will be created.

# Reverse the changes to your template file and save.

# Update Blog via PW Admin as usual (to version 1.2)

# Copy blog.css to /site/templates/css/

blog-upgrade-version1-2.txt

If you are using the blog-side-bar.inc you might want to make/note the following changes. This only affects existing Blog installs! (not new ones)

There was a missing <br> tag + $item->date instead of $item->blog_date. This will ensure Recent Comments widget also show the Post's date. If you are using the code from this file, you can make the following changes:

OLD:

$date = $blogOut->formatDate($item->date);
$out .= "<li><span class='date'>$date</span> <a href='{$item->url}'>{$item->title}</a></li>";

NEW:

$date = $blogOut->formatDate($item->blog_date);
$out .= "<li><span class='date'>" . $date. "</span><br> <a href='{$item->url}'>{$item->title}</a></li>";

In addition, the code has now been changed not to show 'recent posts widget' on the blog home page. @Adrian idea, thanks!

Screens

post-894-0-20033400-1401805227_thumb.pngpost-894-0-50240100-1401805228_thumb.pngpost-894-0-25658900-1401805233_thumb.pngpost-894-0-51929000-1401805234_thumb.pngpost-894-0-17408000-1401805231_thumb.pngpost-894-0-63958900-1401805229_thumb.png

Happy blogging! O0  :lol:

  • Like 7
Link to comment
Share on other sites

ASAP i will provide german language files... ;) Great Work!

Thanks! I think there are a few remaining strings that need to be made translatable as well like the 'No' and 'Yes' for published posts. I'll get to them later. 

Link to comment
Share on other sites

Kongondo. I am in awe!  WOW, WOW, WOW!!!  My mouth has dropped to the floor and my prayers have been answered! This has been designed so beautifully, logically, and intuitively  :'(You are super talented my friend. This is something that has been needed for quite some time. Thank you so much for this!!!

I'm speechless.

  • Like 4
Link to comment
Share on other sites

....Does this module work in multilingual environments (german + english)?

Thanks!

I have never worked in a multilingual ProcessWire environment so I hope my answer doesn't seem foolish :D

Output strings are all translatable. See posts above; someone has worked on/produced German translations. There's maybe 1 or two texts not yet made translatable but will do a final check soon...

Glad you like the module :-)

Link to comment
Share on other sites

i'l translate the actual version - but last days was very bussy...

only problem that i'll see for now is the handling of dates and the calendar overview....this should changed to a multilingual version....i thought i've read a snippet for this from Apesia that support something simiar for displayed calendars, too....

  • Like 1
Link to comment
Share on other sites

here we go  == German language for ProccessBlog

i'll need this great Addon in some weeks for a own blog, so i will contribute some more lost strings that are not translatable until now....so stay tuned.

Thanks to Kongondo! This is really great Addon - i'll love ProcessWire at the first glance it is perfect to setup websites and get learning PHP faster!

  • Like 4
Link to comment
Share on other sites

I have built a few websites on Processwire now but for some reason cannot rap my head around implementing this blog into my current design. I don't understand why you have so many template files and how to edit or get things to output in my html/css coded pages. I would like to just be able to plug the right calls into my current design. Please advise. Complete stuck trying to implement this into my current design.

Link to comment
Share on other sites

Franko,

Sorry to hear you are having problems implementing Blog. Apologies, I have not had time to write the documentation. It is however quite easy to fit Blog in any design. The reason for the 'many' template files is explained in several posts in this thread :-). In a nutshell, the many template files have nothing to do with the module; they are only examples, are necessarily verbose and are meant to showcase the methods/functions available within MarkupBlog. Blog is a module and you can call it anywhere, any time you want in your template files. I will write up what its methods do and how to use them when I get some time. 

  • Like 1
Link to comment
Share on other sites

Ok, so maybe you can point me in the right direction. How do I output my code? I edited the template files with my html and added the php calls you had in your template files. That seems to work, but there is a bunch of code outputting that is not mine and messing things up. I'm assuming that I need to edit the MarkupBlog.module file? The only thing is I can't figure out what needs to be changed in that file to output my html. I'm also assuming that I change the things where there is code listed after all the $out .=   but there seems to be a lot of code that that I do not need. Please advise. 

Link to comment
Share on other sites

No. Do not edit MarkupBlog.module. On update, your changes will just be overwritten. In addition, remember, this is a Markup Module; such modules output some markup. The markup has IDs and classes that you can target with your CSS and do whatever you wish.

What do you mean by messing things up? What template file are you referring to? Even blog.css is just a demo file. If you are using that, you can delete it or use it as a baseline for your blog. Same goes for pocketgrid.css. 

Using the example template file blog-post.php (for single posts), to get you up and running quickly, only use the PHP up to line 48. Delete the rest of the HTML below. However, to output the main content of the post, you will need to echo somewhere $content. In that example template file, I have called that variable $content; it could be anything you want. Still on this example, I include the right sidebar stuff using blog-side-bar.inc. You may choose to do it differently. Have a look at the code in there to see how simple it is. My guess is that you are new to PHP? Anyway, try that first and let me know. Are you developing locally or there is a test site I could look at?

Link to comment
Share on other sites

Yes I am new to php. Ok so I am now assuming that I need to write the php in the top section of the page and echo the content with the tag on the page. I then need to write the css based on the output of your code that comes out when it is echo on the page. Correct?

Here is my code which is different from what outputs. Some elements like the <article> are repeating.

<section id="content" class="cols-a">
<div class="news-a">
<article>
<header>
<p>Thursday, April 3, 2014</p>
<h2><a href="./">Safety Tips for the Garage</a></h2>
</header>
<figure><img src="http://placehold.it/660x160" alt="Placeholder" width="660" height="160"></figure>
<p>You have taken special care to be sure that your home is safe. If you have small children, you’ve childproofed the electrical outlets. If you have older children, you’ve discussed Internet safety and might have installed a filter to block objectionable material. You likely have used baby gates, screened babysitters, and are careful when you use a ladder. Undoubtedly, safety is important. Many times, however, safety issues in the garage are unintentionally overlooked, because the area is not seen as an actual room that your family lives in. Here is a list of things to double check to be sure that your garage is as safe as possible...</p>
<p class="link-b"><a href="./">Read more</a></p>
</article>
</div>
</section>
 
The article section needs to repeat for each post like in the image. screenshot.png
 
 
This is whats outputting
 
screenshot2.png
 
 
 
 
This is the code I am using in the page.
 
    //main content
    $limit = $page->blog_quantity;//number of posts to show on Blog Home Page (pagination kicks in if more posts than limit)
    $content = '';
    $content .=  $blogOut->renderPosts("limit={$limit}");
 
So I am not sure how to get it to output that I want. My lack of php skills is most likely the problem but I have come to love Processwire over Wordpress and Modx. Any help would be appreciated. 
 
Link to comment
Share on other sites

- For "Read more" funktionality you should take a look at the settings in the "posts" Page for truncate...

- like i see in the example files there is no imageoutput maybe her could konkondo give a best practise example that fits the example templates that ships with the MarkupBlog

- the templates for the main output is

  • the blog-post - how look a single post
  • and the blog-posts - overview of all posts
  • and the blog template with a little different overview

there is always a php setting for the content and some vars and below there is the HTML Markup Output.

Or you could write your own template for overview and single-post view and grab the content like shown in example template files direct in your HTML via the PW API.

kind regards mr-fan

Link to comment
Share on other sites

  • 2 weeks later...

This module looks awesome - thanks hugely for sharing :)

Could I ask (pretty new to Processwire so apologies if this is easy or not possible or anything like that). Would it be possible to modify the post URI so that instead of something like /blog/posts/this-is-a-post you could have something like /blog/2014/06/this-is-a-post

So essentially it'd categorize the posts into year and month. This is similar to how Wordpress and a couple of other CMS/Blog systems do it as default, and it's pretty handy as if you've got 2 posts with the same name, they are less likely to clash if you're also including/checking the month/year.

Also, I read through the thread and saw a mention of having a publish date/time - has this been implemented? If not I'm probably going to be doing some work on a few of my own modules in the next week or two, so would be happy to see about doing a pull request with it as it's something I'll need to add anyway :)

  • Like 1
Link to comment
Share on other sites

Also, I read through the thread and saw a mention of having a publish date/time - has this been implemented? If not I'm probably going to be doing some work on a few of my own modules in the next week or two, so would be happy to see about doing a pull request with it as it's something I'll need to add anyway :)

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 :)

  • Like 2
Link to comment
Share on other sites

Seriously? If yes, out of the box, no. But with some trickery, you can have MarkupBlog output posts from only a particular author, assuming each author has their own blog. I am just thinking out loud here. If this is a feature request, I'd like to have more details but also hear what others think :-)

Glad you like the module. :D

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 :)

  • Like 1
Link to comment
Share on other sites

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.

One nice thing that Wordpress has is the ability to change the author of a post from the person who is creating it and logged in. Maybe an author PageField that allows you to select from other PW users that have a blog author role, or something along those lines?

  • Like 1
Link to comment
Share on other sites

One nice thing that Wordpress has is the ability to change the author of a post from the person who is creating it and logged in. Maybe an author PageField that allows you to select from other PW users that have a blog author role, or something along those lines?

Adrian, you can already change the author of the post..unless am not getting you? Check the settings tab when editing a blog post page

  • Like 1
Link to comment
Share on other sites

One nice thing that Wordpress has is the ability to change the author of a post from the person who is creating it and logged in. Maybe an author PageField that allows you to select from other PW users that have a blog author role, or something along those lines?

Agreed. This might be a valid solution for the user-specificity part, though "regular" bloggers probably shouldn't have the permission to do this -- right?

Whether this solves the question of having multiple separate blogs still doesn't seem entirely obvious to me. In another system we've used it was possible to create and embed separate blogs, with their own names and other settings, to different parts of the site. That was pretty handy, actually. Each blog being tied to one user account (in a way that made it impossible to change later) was the problematic part.

If only we could somehow had both.. :)

Edit: I'll have to take a closer look at post settings based on @kongondos reply above, but just wanted to clarify the part about "regular bloggers' permissions". In our case bloggers are sometimes actually users that have absolutely no other permissions -- can't edit content etc. Them being able to edit other bloggers' posts or change authors of those would be far from optimal. Could be specific to our case, though..

Edited by teppo
Link to comment
Share on other sites

Guys,

Sorry I have been rather quiet in the recent past. You may have noticed I am in holiday mode and have been following, rather keenly, the trajectory of a certain spherical leather object :P  :lol: ....Two more weeks to go and I should be back in play....(forgive the pun  O0 )

  • Like 5
Link to comment
Share on other sites

Adrian, you can already change the author of the post..unless am not getting you? Check the settings tab when editing a blog post page

Sorry - I haven't actually implemented your blog profile on a site yet, so I forgot about that!

Agreed. This might be a valid solution for the user-specificity part, though "regular" bloggers probably shouldn't have the permission to do this -- right?

Whether this solves the question of having multiple separate blogs still doesn't seem entirely obvious to me. In another system we've used it was possible to create and embed separate blogs, with their own names and other settings, to different parts of the site. That was pretty handy, actually. Each blog being tied to one user account (in a way that made it impossible to change later) was the problematic part.

If only we could somehow had both.. :)

Edit: I'll have to take a closer look at post settings based on @kongondos reply above, but just wanted to clarify the part about "regular bloggers' permissions". In our case bloggers are sometimes actually users that have absolutely no other permissions -- can't edit content etc. Them being able to edit other bloggers' posts or change authors of those would be far from optimal. Could be specific to our case, though..

In Wordpress regular bloggers can't change the author - it requires an editor (or maybe admin, I don't remember) level permission setting.

Link to comment
Share on other sites

This module looks awesome - thanks hugely for sharing :)

Could I ask (pretty new to Processwire so apologies if this is easy or not possible or anything like that). Would it be possible to modify the post URI so that instead of something like /blog/posts/this-is-a-post you could have something like /blog/2014/06/this-is-a-post

So essentially it'd categorize the posts into year and month. This is similar to how Wordpress and a couple of other CMS/Blog systems do it as default, and it's pretty handy as if you've got 2 posts with the same name, they are less likely to clash if you're also including/checking the month/year.

Also, I read through the thread and saw a mention of having a publish date/time - has this been implemented? If not I'm probably going to be doing some work on a few of my own modules in the next week or two, so would be happy to see about doing a pull request with it as it's something I'll need to add anyway :)

Hi Rickm,

Glad you are liking the module.

URI:

I see your point. There was a similar request a couple of posts further up. My response then and still is that this is one of those things where people have different preferences. Sorry, for now, I am leaving it up to the user to manipulate the URL segment if they so wish.

Publish date/time:

I haven't had time to implement this yet (sorry, distracted by football currently  :P) but it's on my TODO list. 

Thanks!

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...