Jump to content

Module: Blog


kongondo

Recommended Posts

Not directly, its not. But with a custom script it is possible; something to tell Blog about the IDs of your comment related pages and that comments feature is enabled.

Alternatively, if you know what you are doing and TESTING on a development server first, you can directly edit the necessary values in your database using a programme like phpMyAdmin. The code below is from a fully installed blog, in the PW db table 'modules' and the row 'ProcessBlog'. It tells you what is going on.

{"blogFullyInstalled":1,"blogStyle":1,"schedulePages":0,"commentsUse":1,"templateFilesInstall":2,"tagTemplatesFields":"blog","blog":2480,"blog-posts":2481,"blog-categories":2482,"blog-tags":2483,"blog-comments":2484,"blog-widgets":2485,"blog-authors":2486,"blog-archives":2487,"blog-settings":5190,"blog-asc":4017,"blog-dnc":4018,"blog-dc":4019,"blog-rposts":2491,"blog-rcomments":2492,"blog-broll":2493,"blog-tweets":2495,"blog-pauthor":4015}

In your case, you would first need to create the four comments pages and note down their IDs.

blog-comments":2484" - comments (parent of below three)

blog-asc":4017, - always show comments

"blog-dnc":4018, - disable new comments

"blog-dc":4019 - disable comments

There is also the recent comments page to install under widgets.

blog-rcomments":2492

You would also have to create the necessary fields that go with those pages as in a full blog install. 

Then it would be a matter of simply adding the above key/value pairs that have the IDs of your newly created comment page. This would be faster than writing a custom PHP script :-)

You would also need to change this:

"commentsUse":1, in your case the value is '0' - it would need to be changed to '1'

It is not as complicated as it sounds but like I said, you would need to try and thoroughly test on a development install first! If you want to go this route (rather than install afresh), I suggest you fully install blog on a test server and compare the above db values to your current install that's missing the comments feature as well as compare their respective Blog Pages tree....I think that's it really...

  • Like 1
Link to comment
Share on other sites

@ kongondo: Thank you for your fast reply.

I will try it out but I am considering making a fresh install because its a new blog with still a couple of artikels. The neccesarry testing should take up at least the same amount of work.

Link to comment
Share on other sites

@ kongondo

I’ve been playing around with processblog for a week and uninstalled etc etc.

I finally found out a few things that are going wrong during the install:

1. The processwire install uses this file structure for the default template:

errors
scripts
styles

2. But when installed the source shows:

<link rel="stylesheet" href="/pw/site/templates/css/pocketgrid.css" /><!-- The PocketGrid -->

<link rel="stylesheet" href="/pw/site/templates/css/blog.css" /><!-- Custom Styles -->
 

This means these css files are never accessed. If I copy them manually they work, sort of. My blog looks nothing like the screenshort consisting of only 1 column etc.

Ive installed and re installed in different directories etc, but it makes no difference. I've manually created the css directories and copied the files over into the tempaltes directory which changes some of hte colours/formatting but it's clearly not picking up all the files it needs.

How can I install processblog into processwire to make sure it works?

I can only think that the blog.js etc files aren't being referenced?

tia

Link to comment
Share on other sites

Hi @loopyloo. 

Welcome to the forums and thanks for trying out Blog.

If you want to install Blog with the demo content, you have to manually copy over those two CSS files and the blog.js file to some folder in your /site/templates/. If your paths are different, you would have to change them in 'blog-main.inc'. Check in Firebug/Chrome Developer that the files are actually being loaded. In case you missed it, let me also reiterate that the demo Blog is just that - a demo; you will probably want to change it here and there to suit your needs :-).

Link to comment
Share on other sites

Hi,

This is a default 2.5.2 processwire install so I havent changed my paths...

So just to be clear I have to change all the referenced files in blog-main.inc before installing ProcessBlog? Or can I change them after? Should blog-main.inc be in the site/templates folder as it's not there in my installation

tia.
 

Edit:

I have reinstalled and can see the blog but the formatting/layout is incorrect. I've moved:

css/pocketgrid.css

css/blog.css

js/blog.js

into site/templates
post-2987-0-43859700-1420031901_thumb.jp

Link to comment
Share on other sites

After (but only if necessary - see below). As outlined in the must README :-)

  • If you chose to install the demo Template Files, also manually copy over the /css/ and /js/ folders present in Blog module's folder to your /site/templates/ folder.

+ You have to manually copy over the files CSS + JS files. If you don't copy them to /site/templates/css/ and /site/templates/js/ then, you have to amend the links in blog-main.inc (e.g. you could have copied them to /site/templates/styles/ and /site/templates/scripts/ respectively. 

Have you confirmed that the files are being loaded in the browser. If your answer is yes, then the problem I suspect is that the default PW install _init.php and/or _main.php files are interfering with the rendering. It has happened to me before :-). I always use the PW blank install so I don't tend to notice this much. 

If blog-main.inc wasn't copied to over to /site/templates/ it means you did not install Blog with demo content :-)

Maybe send some screenshots of your settings when you initially set up blog (step 1 in the module config) + what your frontend looks like. 

Link to comment
Share on other sites

HI,

I was literally about to post the same thing, this second.

Here is what has happened if anyone else is experiencing this issue:

1. Install XAMMP on windows

2. Install bitnami processwire. Here is where we have the first problem. The bitnami processwire install does NOT allow you to choose which site template and installs the intermediate site template by default. You CANNOT choose an empty site.

3. If you do a manual install of processwire you can install a blank site.

4. When you install processblog, copy over the CSS and JS folders, or edit the blog-main.inc to point to the where you have copied the new files.

5. Edit EACH template file in the BLOG section (Admin > Setup > templates > files >

tick the checkbox " Disable automatic append of file: _main.php"

then the blog will work.

6. To make things additionally confusing (to a beginner) :-) the intermediate site template has home/about links as does the blog and the blog jumps back to the main site intermediate template.  The home / about / links are completely different.

To reiterate, the Bitnami processwire install does not allow a blank site template.

 

post-2987-0-27032000-1420033150_thumb.jp

  • Like 1
Link to comment
Share on other sites

No problem, Just took me a week to figure out what was going on. When I did a manual install I noticed I could choose site template whereas the Bitnami processwire installer didn't.

What would be really helpful is if in the ProcessBlog page on the module download ...

http://modules.processwire.com/modules/process-blog/

...you put a screenshot of what the blog should look like. (eg above picture in post) I could not figure out what the blog was supposed to look like so kept modifying things trying to get it to work. If i had an image to refer to I would have known straight away something was wrong.  To those familiar with processwire/css/php it would have been apparent but I am completely new to processwire :-)

thanks

Link to comment
Share on other sites

Thanks for the help! I think processwire is great and your blog is a great step as it saves so much work.

Oh also may be a good idea to add it to the first screenshot in this forum section as you have the admin pages but not what it looks like at the front end.

I know the video has a finished site (last link), but it wasn't clear what a default site would look like)

Link to comment
Share on other sites

Hi @Kongondo,

Happy New Year to everyone!

When using renderPosts with "small" set true, the text that is output takes any headings in the post (h2's in my case), strips the h2 elements, leaving the rendered h2's innerText in-line with the body copy.

The headings are not meant to be read in-line and as a result, what is output in the summary rendering doesn't read very well. 

As everything is output in a single paragraph, I guess I need to have the headings completely stripped out of the copy. I can't believe this hasn't happened before - any thoughts, recommendations?

Cheers! :)

Link to comment
Share on other sites

@Gazley,
 
Yes, it has happened before and we've dealt with it as shown here using 'post_small_allowable_tags'. Specify and configure that as you wish in your renderPosts() third argument $options.

//holds string of HTML tags for strip_tags $allowable_tags. Needs to be in format '<code><p><img>'
$options = array('post_small_allowable_tags' => '<h2><img>',//etc..);

Sorry, still haven't gotten round to updating the docs! So, that post #207 is your go to post :-)

Link to comment
Share on other sites

Hi @Kongondo,

Just a heads-up, I'm noticing that the markup returned by renderPost "small" returns an uneven set of <p> elements. In my case, the markup encounters a ... </p> which is followed later on by <p> .... </p>.

I noticed this by passing the code into a DOM parser that was choking on the uneven elements.

Can you confirm you see this too?

Cheers!

Link to comment
Share on other sites

Hi @Kongondo,

Sorry my previous post was a "red-herring". The <p> were balanced. The problem is that now I am allowing 'h2' elements through, the blog markup code is wrapping the 'h2' element pairs in 'p' tags which is in-turn causing the DOM parser to choke.

I assume that from the HTML DOM perspective, you cannot have a heading element inside a paragraph element?

Cheers!

Link to comment
Share on other sites

Hi @Kongondo,

This appears to be a slightly more tricky problem than originally anticipated. I thought I had a workaround to the issue by stripping out the embedded 'h2' elements from inside the paragraphs and replacing them with an empty string. This worked until I tested with different posts with differing text and headers. I ended up hitting the same issue again with the DOM parser choking because the post truncating code that makes the post "small" did not take account of the need for a closing 'h2' element and inadvertently trims the small post string with a now malformed 'h2' element (it has a <h2> but no </h2>). This means that my parsing RegExp fails because it aims to replace <h2>...</h2> and of course, the </h2> may have been trimmed by "smallification". In any event, I'm still left with a paragraph that contains an <h2> that isn't closed which I still incorrectly formed HTML.

I hope this makes sense! :)

Cheers.

Link to comment
Share on other sites

@Gazley,
 
Yes, you are right about what elements can be nested in what. Thanks for helping me rethink this.
 
For the benefit of others, below is a lengthy explanation + the solution I propose (you can skip right to it :-))
 

HTML does not allow nesting of <p> (or other block level elements):
Because a paragraph is a paragraph .. and that's how HTML is defined (and HTML is not XML).
Any <p> (or other block-level element) will implicitly close any open <p>.
Per 9.3.1 Paragraphs: the P element of the HTML 4.01 specification:
The P element represents a paragraph. It cannot contain block-level elements (including P itself).

 
Resources:
http://www.w3.org/TR/html401/struct/text.html#h-9.3.1
http://stackoverflow.com/questions/12015804/nesting-p-wont-work-while-nesting-div-will
http://ckeditor.com/forums/Support/Nested-paragraph-tags.
http://webtips.dan.info/nesting.html - old but good
http://www.iamchristinabot.com/blog/20110519/why-do-nested-html-paragraphs-break-css/
http://stackoverflow.com/questions/4291467/nesting-block-level-elements-inside-the-p-tag-right-or-wrong
 
Explanation:
First the code in MarkupBlog.module

//MarkupBlog Line #933
//notice the surrounding '<p></p>' tags
if($small) $out .= "<p>" . $page->summary . "… <a class='more' href='{$page->url}'>" . $options['post_more_text'] . "</a></p>";

In your template file e.g. 'blog-posts.php', assuming you have this code:

$options = array(
   'post_small_image' => 3,//here for array illustration only
   'post_small_image_width' => 250,//ditto
   'post_small_allowable_tags' => '<h2>',  
);

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

Example content entered in your 'blog_body'

<p>This is my paragraph that I am going to test.</p>
<p>Here comes a second paragraph.</p>
<h2>And here comes a h2 we will allow through.</h2>
<p>This is another paragraph.</p>
<p>Our final paragraph.</p>
<h2>A second h2 to allow.</h2>

1. Output without 'post_small_allowable_tags'

<p>This is my paragraph that I am going to test. Here comes a second paragraph. And here comes a h2 we will allow through. This is another paragraph. Our final paragraph. A second h2 to allow</p>

2. Output with 'post_small_allowable_tags'
In the second output, since you have allowed <h2> (it doesn't matter whether they came first or in-between other text in your content), this is what line #933 will send to the browser:

<p>.....<h2>........</h2>..........<h2>........</h2>..</p>;

As stated, that is invalid code and the browser will remedy it. The next block level element will be used to close the first <p> or the browser will self-close it (empty <p></p>). So, what you will end up with in the browser is:

<p></p><h2>....</h2>some free untagged text<h2>....</h2></p>.

Although the browser (view source) will seemingly also place an empty <p></p> at the end of the text, in fact, it will just be a closing </p> without an opening <p>. The W3C validator will then give you the error 'No p element in scope but a p end tag seen.'
 
For comparison, if you allowed an inline element, e.g. <img> tag instead

$options = array('post_small_allowable_tags' => '<img>');

This would be output correctly since an <img> is an inline element. The output would be:

<p>Some text<img>More text<a>Read More</a></p>.

Hopefully this long explanation will help inform decisions about how to use the solution I envisage.
 
Solution
I will make what HTML element (or not) to surround a blog excerpt (blop post small) with configurable (add to $options). So:

  • Let user decide whether to surround post excerpt with <span>,<p>, nothing, etc. since they know what tags they will be making 'allowable' (inline vs block level).
  • The option will apply whether using 'post_small_allowable_tags' or not.
  • Default will be to surround with <p>.
  • An empty value passed to the option will mean 'do not surround the excerpt with anything'.
  • I will also add a class to that tag, e.g. <p class='post-excerpt'>...</p> to aid with more specific style-targeting.

Hope to update this soon. The update should not break any existing installs since it will default to the current use of <p></p> tags.

  • Like 2
Link to comment
Share on other sites

Hi kongondo, thank you for the awesome module!
 
I have just installed the module on a site I am currently developing and am now getting an issue when I go to the blog control panel I get the following error:
 
FieldtypeComments: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'field_blog_comments_votes' already exists

There was another error stating that field_blog_comments did not exist when I first went to the blog control panel but that one has cleared and the table does exist.

But I can't seem to figure what is the issue with this error. Have tried removing and uninstalling and then re-installing to no avail.

Any help would be greatly appreciated.

Many Thanks,

Alex

Link to comment
Share on other sites

Hi Alex,

Thanks for trying out Blog.

Most likely you are hitting the limits of xdebug.max_nesting_level=100; so the Blog wizard is not completing the installation.

Please check out these posts to see if they resolve your issue:

Link to comment
Share on other sites

Thank you for the reply! Much appreciated.

So I did a cleanup, then removed field_blog_comments_votes which didn't get deleted from the DB and then did an uninstall of the blog module, then increased the limit of xdebug.max_nesting_level to 200 in php.ini and then tried a re-install and got the same/similar issues at the same point. Have attached a screenshot if you get chance to take a look.

Sorry for the trouble.

post-2189-0-97678900-1420507724_thumb.pn

Link to comment
Share on other sites

Thank you for the reply! Much appreciated.

So I did a cleanup, then removed field_blog_comments_votes which didn't get deleted from the DB and then did an uninstall of the blog module, then increased the limit of xdebug.max_nesting_level to 200 in php.ini and then tried a re-install and got the same/similar issues at the same point. Have attached a screenshot if you get chance to take a look.

Sorry for the trouble.

Yeah i had those issues, What i did was usually use ProcessMigrator and revert or delete those fields using ProcessBatcher as deleting one by one takes time.

Link to comment
Share on other sites

@Alex,

I am wondering whether it is because of this? field_blog_comments_votes. This is the latest comments module. I haven't tried it out with Blog and seems like I should. The error suggests it has something to do with it (i.e. it is not being uninstalled, I think). Have you confirmed in your db that the field is actually removed before trying to reinstall Blog? Same goes for the other tables. Meanwhile I'll find some time to try out Blog with the latest comments module...

Link to comment
Share on other sites

Yea each time the field sticks in the DB so I manually remove it before trying again.

Have just tried re-installing again now but it's all gone mental now and am getting about 28 or so errors now. Ahhhhh. 

Dunno what's happening. Haha. 

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