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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
×
×
  • Create New...