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 kixe
      Field that stores one or more references to ProcessWire pages with additional data in field context.
      Values are editable via page edit modal of the referenced page provided from the field if module AdminPageFieldEditLinks is installed and "Enable link to create new pages?" is checked in field settings.
      Requirements: AdminPageFieldEditLinks >= 3.1.4
      https://github.com/kixe/FieldtypePageContextData
      https://processwire.com/modules/fieldtype-page-context-data/
      Use case example:
      The planning of the Tonmeistertagung in the CCD (Congress Center Düsseldorf) from November 3rd, 2021 to November 6th, 2021 is in the finalization phase.
      The conference consists of a conference part and an exhibition. The planning is done via a separate frontendless PW instance. There, all companies (pages) that are active at various events are kept in a pool. Changes (address, logo) can always be done there. For the exhibition of the current conference in November, the exhibitor-companies (pages) are selected via a page reference field. A stand number must now be assigned to each selected company (page). We had originally solved this using the Profield FieldtypeTable. However, this had the disadvantage that each entry again made all companies available for selection and did not recognize which were already selected in a previous table row. The new field type now allows the value (company's stand number) to be assigned to a Company (page) in context to a specific Pagefield living in a specific page.
      https://tonmeistertagung.com/en/exhibitors/exhibition/
       
    • By Robin S
      This module lets you add some custom menu items to the main admin menu, and you can set the dropdown links dynamically in a hook if needed.
      Sidenote: the module config uses some repeatable/sortable rows for the child link settings, similar to the ProFields Table interface. The data gets saved as JSON in a hidden textarea field. Might be interesting to other module developers?
      Custom Admin Menus
      Adds up to three custom menu items with optional dropdowns to the main admin menu.
      The menu items can link to admin pages, front-end pages, or pages on external websites.
      The links can be set to open in a new browser tab, and child links in the dropdown can be given an icon.
      Requires ProcessWire v3.0.178 or newer.
      Screenshots
      Example of menu items

      Module config for the menus

      Link list shown when parent menu item is not given a URL

      Advanced
      Setting child menu items dynamically
      If needed you can set the child menu items dynamically using a hook.
      Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $colours = $event->wire()->pages->findRaw('template=colour', ['title', 'url', 'page_icon']); $children = []; foreach($colours as $colour) { // Each child item should be an array with the following keys $children[] = [ 'icon' => $colour['page_icon'], 'label' => $colour['title'], 'url' => $colour['url'], 'newtab' => false, ]; } $event->return = $children; } }); Create multiple levels of flyout menus
      It's also possible to create multiple levels of flyout submenus using a hook.

      For each level a submenu can be defined in a "children" item. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $children = [ [ 'icon' => 'adjust', 'label' => 'One', 'url' => '/one/', 'newtab' => false, ], [ 'icon' => 'anchor', 'label' => 'Two', 'url' => '/two/', 'newtab' => false, 'children' => [ [ 'icon' => 'child', 'label' => 'Red', 'url' => '/red/', 'newtab' => false, ], [ 'icon' => 'bullhorn', 'label' => 'Green', 'url' => '/green/', 'newtab' => false, 'children' => [ [ 'icon' => 'wifi', 'label' => 'Small', 'url' => '/small/', 'newtab' => true, ], [ 'icon' => 'codepen', 'label' => 'Medium', 'url' => '/medium/', 'newtab' => false, ], [ 'icon' => 'cogs', 'label' => 'Large', 'url' => '/large/', 'newtab' => false, ], ] ], [ 'icon' => 'futbol-o', 'label' => 'Blue', 'url' => '/blue/', 'newtab' => true, ], ] ], [ 'icon' => 'hand-o-left', 'label' => 'Three', 'url' => '/three/', 'newtab' => false, ], ]; $event->return = $children; } }); Showing/hiding menus according to user role
      You can determine which menu items can be seen by a role by checking the user's role in the hook.
      For example, if a user has or lacks a role you could include different child menu items in the hook return value. Or if you want to conditionally hide a custom menu altogether you can set the return value to false. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); $user = $event->wire()->user; // For custom menu number 1... if($menu_number === 1) { // ...if user does not have some particular role... if(!$user->hasRole('foo')) { // ...do not show the menu $event->return = false; } } });  
      https://github.com/Toutouwai/CustomAdminMenus
      https://processwire.com/modules/custom-admin-menus/
    • By tcnet
      This module for ProcessWire sends a notification email for each failed login attempt. Similar modules exists already in the module directory of ProcessWire. However, this module is designed to notify, even if specified user doesn't exist.
      Settings
      The settings for this module are located in the menu Modules=>Configure=>LoginFailNotifier.
      Notification email
      Specifies the email address to which the notification emails should be sent.
        Email subject
      Specifies the subject line for the notification email.
        Post variables
      Specifies the $_POST variables to be included in the notification email. Each variable must be separated by a comma. For example: login_name,login_pass
        Server variables
      Specifies the $_SERVER variables to be included in the notification email. Each variable must be separated by a comma. For example: REMOTE_ADDR,HTTP_USER_AGENT
      Link to ProcessWire module directory:
      https://processwire.com/modules/login-fail-notifier/
      Link to github.com:
      https://github.com/techcnet/LoginFailNotifier
    • By Fokke
      ProcessWire 3.x markup module for rendering meta tags in HTML document head section. Note that this module is not a full-blown SEO solution, but rather a simple tool for rendering meta tags based on module configuration. Adding custom meta tags is also supported.
      Built-in meta tags
      The following meta tags are supported out-of-the-box:
      Document title consisting of page title and site name Character set Canonical Viewport Description Keywords Hreflang tags Open Graph og:title og:site_name og:type og:url og:description og:image og:image:width og:image:height Twitter meta tags twitter:card twitter:site twitter:creator twitter:title twitter:description twitter:image Facebook meta tags fb:app_id The full documentation with configurable options can be found here: https://github.com/Fokke-/MarkupMetadata
       
      Requirements:
      ProcessWire>=3.0.0 PHP >=7.1 Installation using Composer
      composer require fokke/markup-metadata Manual installation
      Download latest version from https://github.com/Fokke-/MarkupMetadata/archive/master.zip Extract module files to site/modules/MarkupMetadata directory.
    • By m.sieber
      ITRK-Service for ProcessWire
      Module for the automated transfer of imprint, data protection declaration and terms and conditions from IT-Recht Kanzlei to your ProcessWire installation
      What is ITRK Service for ProcessWire?
      ITRK-Service for ProcessWire is a free module for ProcessWire CMS. It provides an interface to the update service of IT-Recht Kanzlei, via which the legal texts of your online presence are automatically updated. In this way, the texts remain legally secure and warning-proof in the long term. Imprint, data protection declaration, revocation and general terms and conditions are currently supported.
      You can find our documentation (in german language) here: https://www.pupit.de/itrk-service-for-processwire/dokumentation/

      Download: https://www.pupit.de/itrk-service-for-processwire/
      Github: https://github.com/pupit-de/pwItrkServiceConnector
×
×
  • Create New...