Jump to content

Module: Blog


kongondo

Recommended Posts

Thanks for the suggestion, glad I've not missed something silly.

Can I check—should I have installed FieldtypeComments prior to Blog or does Blog auto install this?

BTW Blog is such a comprehensive and polished Module, it's almost doing it a disservice to call it a Module, it's more like a mini app; thank you.

Link to comment
Share on other sites

Can I check—should I have installed FieldtypeComments prior to Blog or does Blog auto install this?

Blog doesn't install FieldtypeComments. I'm not sure but I think it is auto-installed when you install ProcessWire.

BTW Blog is such a comprehensive and polished Module, it's almost doing it a disservice to call it a Module, it's more like a mini app; thank you.

Glad you like it. Thanks!

Link to comment
Share on other sites

Hi folks, I just try a single template with the Process Blog implement.
I have a head.inc, footer.inc etc created and leave only the main body in the _main.php.

Thus, everything comes together in the _main.php.

Now to my problem: When I'm on the home page, then he shows me where the sidebar is included from Process Blog an "Internal Server Error".

Had ever jeman the problem and or how do I fix it?

Thanks for your help.

Link to comment
Share on other sites

Hey csaeum,

If you are developing a site it's good practice to turn on debug mode. This will make sure that errors are sent to your screen. You can enable this in /site/config.php. By default, it is false. Change it to true.

$config->debug = true;

Remember to turn it off on a live site. 

Please post the error and we are here to help.

Link to comment
Share on other sites

OK Thanks for Help

Here the Error:

Error: Call to a member function formatDate() on null (line 24 of /home/moebrdbr/www.pw.landhausstil.info/site/templates/blog-side-bar.inc)

This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged.

If I am in the blog even then the error is not only on the home page.

See here: http://www.pw.landhausstil.info/

Edited by csaeum
Change colour of the error message so it can be easily read.
Link to comment
Share on other sites

What version of Blog are you using?

I am also not sure what exactly you changed/didn't change (from your explanation above - where you talk about header.inc and _main.php)

This error:

Notice: Undefined variable: blog in /home/moebrdbr/www.pw.landhausstil.info/site/templates/blog-side-bar.inc on line 24

says you have a variable called blog ($blog) in there somewhere (in blog-side-bar.inc). 

This one...

Fatal error: Call to a member function formatDate() on null in /home/moebrdbr/www.pw.landhausstil.info/site/templates/blog-side-bar.inc on line 24

says you the function formatDate cannot find a field called blog_date or that the field is empty (no date entered).

Could you paste the contents of your blog-side-bar.inc below?

By the way, the template files that come with Blog are there really for demonstration purposes. For instance, I hope don't have line #64 in the demo and other subsequent code in your implementation.

Link to comment
Share on other sites

Thanks kongondo re

Blog doesn't install FieldtypeComments. I'm not sure but I think it is auto-installed when you install ProcessWire

and

Otherwise this really is a FieldtypeComments question (a core module) since that's what Blog uses.

I'll check if it auto installs and then follow up and ask a Q on github re the core, if I find anything helpful I'll post back here :)

  • Like 1
Link to comment
Share on other sites

Have now updated to the 2.3.8.

Tried to reduce to a round template.

So the Header/Footer and the Mainbody come from one source.

Thus I have the Sidebar_Inc includet in _main.php.

Now, however, a new few errors. I have seen this first. Since I am more of the designer and the programmer less it is again a steep learning curve :)

I'll get back :)

Link to comment
Share on other sites

  • 2 weeks later...

I just added the blog module to a site on a local environment. Almost done with the styling etc. 

When I went to change the settings on the blog dashboard to display summaries, it won't save my changes. 

I went to the .module file and made $small = true and it only picks up what is in the code but does display summaries. 

2 Questions

1.) How can I get the dashboard settings to save?

2.) On the blog-post template I am also displaying summaries instead of the full post ever since I changed $small = true, how can I get the full post for these pages?

Link to comment
Share on other sites

@quickjeff,
 
No need to edit the modules files :-)..
 
#1. I am afraid I don't follow. There is no setting for displaying summaries. Do you mean the setting for Posts summary length? All settings are saving just fine here. What's your environment?
 
#2: $small = false, the default (which you seem to have changed) will display the full post. To display summaries, just call renderPosts() with $small=false. Examples:

// call the module - MarkupBlog
$blog = $modules->get("MarkupBlog");

// render a limited number of summarised posts
$content = $blog->renderPosts("limit=5", true);

// render a limited number of full posts
$content = $blog->renderPosts("limit=5");

Blog API (incomplete) is here

Link to comment
Share on other sites

All is good now with my issue. 

Thank you. 

Now onto another issue, I still cannot save any settings I add in the blog dashboard.  It says it was saved but when I open again, it shows empty fields. 

I am running this on a local install on MAMP. 

So here are my new issues on my 2.7.2 install on a local MAMP environment:

  1. Cannot save settings from dashboard, they dont take affect, only the widget check boxes work.
  2. Comments do not show the formatted date output I am using on the blog_date  they show these numbers 1461862491
Link to comment
Share on other sites

Honestly I'm dumbfounded by this one. Maybe it is a MAMP issue? Did you change any other module code?

  1. What happens is you try to save the settings page directly (/your-blog-page/settings/
  2. That's a timestamp (because of some reason an unformatted blog_date is being returned). Again, I have not see such behaviour nor has it been reported before.
  • Are you able to install Tracydebugger or similar to try and debug this?
  • Are you able to test in a different environment?
Link to comment
Share on other sites

I have had the same Problem with the unformatted date. Using PW 2.7.2 and Blog 2.3.8 running on a SMP Debian 3.2.65-1+deb7u2 x86_64 Server with PHP 5.4.38.

Ashampoo_Snap_2016.jpg

Then I changed

$date = $blog->formatDate($comment->created, 2);

with

$date = $blog->formatDate($comment->created, 2);
$ux2date = date('d.m.Y h:i', $date);
$date = $ux2date;

and this solved the problem for me.

Greetings Tom

Edited by Thomas Möhrling
Link to comment
Share on other sites

Thanks guys... I located the raw date problem...

During the last commit to allow use of date format specified in blog_comments to be displayed for comments I forgot that on a fresh install, one has to first save what is specified in FieldtypeComments's dateFormat for that to kick in (see the fields Details Tab). The default 'relative' is not saved unless the user actually saves the field (normal for fields). So, in our case, the dateFormat was empty and as a fall-back, you were being shown the unformatted date as per line #247 in WireDateTime formatDate(). 

I've committed a fix.

Update: Blog 2.3.9

Fixes above bug :-)

PS: There's still 1 or 2 pending requests that I haven't yet gotten time to address...

  • Like 2
Link to comment
Share on other sites

Hi kongondo,

Sorry to bother you with a question and thanks if you get any time to answer ^_^

If I use the Auto-publish from... field and its date-picker the field gets populated like this

2016-05-16 hh24:05:ss

on clicking Save and keep unpublished I see a session warning/info

Session: The parsed time was invalid (value='2016-05-16 hh24:05:ss', format='Y-m-d H:i:s')

I can manually clean the format or delete out all but the date and all is OK.

Blog is 2.3.9 and PW is 2.7.3

If there is more I can tell you or you'd like me to try something then I'd be only too happy to.

Thanks in advance for any pointers on if I can fix this somehow (I looked at settings of the publish_from field etc but it looks like template blog is overwriting them and when I check there there it looks like they're locked down (not that I would lightly go around editing such an area). Cheers, -Alan

Edit: PS it looks like the Save and keep unpublished cleans the field to something like 2016-05-12 00:05:00 and so I guess the session warning is for my info and the sanitizing of the field chose some defaults from the 'bad' data. Hope that made sense :/

Edited by alan
Link to comment
Share on other sites

Hi,

is this code posted from febuary now part of version 2.3.9?

I can't find the code in the .module.

/**
	 * Return a date formatted as specified in the Blog post's 'blog_date' field.
	 *
	 * @access public
	 * @param int|string $date If given a timestamp, it will be automatically formatted according to the 'blog_date' field in PW
	 *	If given a string, then whatever format it is in will be kept. 
	 * @param int $mode Date format to use. If for posts and similar, use blog_date (default). If for comments, use blog_comments dateFormat.
	 * @return $date string
	 *
	 */
	public function formatDate($date, $mode = 1) {

		if(is_int($date)) {
			// for posts, use date format specified in field 'blog_date'
			$dateFormat = $this->wire('fields')->get('blog_date')->dateOutputFormat;
			// for comments, if specified, use in-built date format in 'blog_comments'
			if($mode == 2 && $this->wire('fields')->get('blog_comments')->dateFormat) {
				$dateFormat = $this->wire('fields')->get('blog_comments')->dateFormat;
			}
			
			$date = FieldtypeDatetime::formatDate($date, $dateFormat);
		}

		return $date;

	}

I still want to translate the last comments date.

Second question for me is, how can i change or disable the "on" in the comments section.

post-3507-0-23885400-1463046894_thumb.pn

post-3507-0-97614600-1463047167_thumb.pn

Link to comment
Share on other sites

Sorry guys for this question but I do not get along with the current sample blog template. I'm not a programmer but more man for CSS and Design.

I once simply a pure HTML page via include integrated into the blog-main.inc and in the _main.php.

This should both unify the whole <head>.

As long as I took everything great only on the home page and thus not the blog. But once I / went to / blog was the <header> as double.

How can I round unify fit. So all that belongs to its place and get out of it, no Server Error's.
https://processwire.com/talk/topic/7403-module-blog/page-32#entry117498

How should I get a basic template for my projects best build it again?

Me is not so clear as the related files, currently seems the _main.php to be parsed and yet this then handed over to the blog or main.php?

Since I am not alzu good programmer I do not know how I currently best so should build a basic template. The whole with _init.php etc I am very unknown. Also, what functions as currently produced.

Link to comment
Share on other sites

@Marcel Epp
 
#1: Yes, the code is right here
#2: My German isn't great but I think you are referring to the Posted by Franz Beck on 11 May 2016. That comes from here, the option post_date_text. As you can see, it is an empty string. My reasoning was that you cannot translate an empty string (although I don't know how the translation parser works). Instead, the idea is that you provide the translation/text yourself like so:

$content = $blog->renderPosts($page, false, array('post_date_text' => 'on'))// whatever you want 'on' to be

@All Others...

Hope to get some time soon to look into your questions...sorry...

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

@kongondo You're generosity at making this excellent module available and providing all the help you do is so much more than one should expect; NO problem re [Hope to get some time soon to look into your questions...sorry...] thanks again for this module and good luck in all your endeavours, cheers ^_^

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

i need some help again. :undecided:

How can i put some text under the headline?

post-3507-0-19604700-1464798558_thumb.pn

I render the posts like this, with an option array and my page counter.

$content = $blog->renderPosts($page, 0, $postoptions) . $page_counter . $blog->postAuthor() . $renderComments . $blog->renderNextPrevPosts($page);//with post author widget

It is possible to have my page counter under the headline?

Link to comment
Share on other sites

@Marcel Epp,

Currently that's not possible, at least not directly. The only option I see is that you get the output of renderPosts(), and do a string replace on the text at the beginning of the post body, i.e replace <div class="post-body">, prepending your page counter to it. Something like:

// the start of the post body to prepend to. This is the string we will search for and replace
$str2Replace = "<div class='post-body'>";
// your counter text + appended start of post body
$page_counter = "<div class='post-counter'><h4>This is text for your post counter</h4></div>" . $str2Replace;
// full post body to search and replace $str2Replace
$postBody = $blog->renderPosts($page, 0, $postoptions);
// the actual search and replace (prepend)
$postBody = str_replace($str2Replace, $page_counter, $postBody);
// final output
$content = $postBody . $blog->postAuthor() . $renderComments . $blog->renderNextPrevPosts($page);//with post author widget
  • Like 1
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...