pkBlog 1.4 is now available, with no need for PHx on your site

20 Sep 2009 MODx

One thing I quickly realized when I tried installing pkBlog on a fresh MODx site was that parts of the entry form were dependent on the PHx plugin. Version 1.3 abolished this dependency, and v1.4 squashed a couple of bugs and added a handy new feature.

I usually try to write an intro that will work as the first paragraph of the complete item, so until now I've been copying and pasting from the Intro box into the main text area. You can't use the standard [+introtext+] placeholder to this purpose, as it seems to be parsed when it's still empty, so I created my own placeholder, which expands on publication to the text of the Intro box.

I also tried installing pkBlog on a new MODx site with the sample content. Ugh! Terrible mess - the CSS file supplied clashes with my own forms styles quite badly. So I expanded the package to include two full site templates (plus stylesheets) that produce a more presentable result. I also rationalized the location of some of the distribution files - chunks in the "chunks" folder, templates in the "templates" folder.

The new package, version 1.4.1, is available from the Downloads page in the pkBlog section, or from the MODx forums In Development area. One day I'll find out how to make updates work in the Extras pages of the main MODx site, meanwhile these are the places you can get the latest version.

You begin to appreciate why people like those one-click plugins on Wordpress so much after a while...


Comments (22)

Steve
Posts: 15
Comment
Thanks for this
Reply #1 on : Fri November 06, 2009, 07:44:08
I'm a new convert to modX and although I have quickly got a site together I wanted a really easy way for a non technical user to manage a news page.
I installed PKBlog and with a few changes to the UI its just what I wanted. The only real problem I had was with image paths. Ultimately I realised that it was because my MAMP php install had magic quotes on. Adding "magic_quotes_gpc = Off" to php.ini solved it. It may be worth mentioning in this in the help files. Thanks again.
jane
Posts: 15
Comment
archiving
Reply #2 on : Wed November 11, 2009, 07:19:42
I just finished going through your instructions on how to setup the PKBlog. Thank you for that! I am also fairly new to modX and so far I am liking it. Just wondering how I could archive or add previous posts and show them like how you do on your site. (Right column) Please help.

Cheers!
kp52
Posts: 6
Comment
archiving - how it's done (here)
Reply #3 on : Wed November 11, 2009, 10:39:22
Hi, both, thanks for sharing your experience!

Re the archive list, the right column in the Pogwatch site templates is set using a snippet that will insert a Ditto or Wayfinder call according to where you are. On the main blog page, the config file for the main content area sets &display=`3`, and the right column snippet inserts this Ditto call (beware extra space after opening brackets, needed to get Jot to display the code instead of running it!):

[ [Ditto? &parents=`2` &orderBy=`pkDate DESC` &start=`3` &tpl=`blog.navStrip` &filter=`pkPreviewFlag,1,2` ]]

The blog.navStrip template chunk looks like this:
<div class="blogArchive"><span>[ +pkDate:date=`%d %b %y`+]</span>
<h4><a href="" title="[ +longtitle+ ]">[ +title+ ] ([ [Jot?action=`count-comments` &docid=``]])</a></h4></div>

When you're viewing an individual post, Ditto uses the same template, with different &display parameters and &tplCurrentDocument to pick out the current item:

[ [Ditto? &parents=`2` &orderBy=`pkDate DESC` &display=`12` &tplCurrentDocument=`blog.current` &tpl=`blog.navStrip` &filter=`pkPreviewFlag,1,2` ]]

template chunk blog.current:
<div class="blogArchive"><span>[ +pkDate:date=`%d %b %y`+]</span>
<h4> [ +title+]</h4></div>

There are probably other solutions, using Reflect, for instance.
Last Edit: November 11, 2009, 12:03:13 by kp52  
jane
Posts: 15
Comment
having issues
Reply #4 on : Wed November 11, 2009, 23:39:38
Thank you for posting the code so quickly, I tried it, but can't get the first portion to work.

I have this in my resource content area of my blog page:





and when I view the page it gives me this error message:

&tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.

Am I doing something wrong or missing stuff? I did create a chunk called blog.navStrip.tpl
jane
Posts: 15
Comment
missing code from post
Reply #5 on : Wed November 11, 2009, 23:41:11
here is the code i have in my resource content area:


[ !Ditto? &parents=`10` &orderBy=`pkDate DESC` &start=`1` &tpl=`blog.navStrip.tpl` &filter=`pkPreviewFlag,1,2`! ]
jane
Posts: 15
Comment
oops
Reply #6 on : Wed November 11, 2009, 23:41:59
[ !Ditto?config=`blog` &display=`3`! ]

[ !Ditto? &parents=`10` &orderBy=`pkDate DESC` &start=`1` &tpl=`blog.navStrip.tpl` &filter=`pkPreviewFlag,1,2`! ]
kp52
Posts: 6
Comment
template code
Reply #7 on : Thu November 12, 2009, 09:58:29
@jane: probably the "does not contain any placeholders" is the key here, if you copied mine from the comment. I had to add spaces between the brackets and plus signs to have the code show up in these comments - did you adjust for that? One reason why the forum is better for discussing details of code - you can display it exactly as it exists in your resource.
jane
Posts: 15
Comment
multiple blogs on one site
Reply #8 on : Wed November 18, 2009, 04:44:39
Hi KP,

Is it possible to have multiple blogs on one site? I have a client that has 3 authors, each would like their own blog section.

Cheers!
John
Posts: 15
Comment
Strip Slashes?
Reply #9 on : Thu November 26, 2009, 19:42:57
Hi, small problem I've encountered. Both the intro text and the content, if there is a ' then when I do a preview or a publish, i get \' in the output. I'm trying to figure out how to add stripslashes() but cant find where it needs to be added.

Note that I already added a
php_flag magic_quotes_gpc Off
in my htaccess but that did not do the trick

Thanks in advance.
John
Posts: 15
Comment
Solved
Reply #10 on : Fri November 27, 2009, 01:23:05
I fixed the problem on my own.

Added these lines

$fields[$rtcontent] = stripslashes($fields[$rtcontent]);
$fields[$rtsummary] = stripslashes($fields[$rtsummary]);

just after line 126
kp52
Posts: 6
Comment
Magig quotes, stripslashes
Reply #11 on : Fri November 27, 2009, 12:49:03
Hi John, glad you have found a solution, though I suspect it will not be a complete one. I find fiddling with corrections to unwanted actions in input/filing/output operations is like nailing jelly to the wall. I'm pretty sure magic quotes is the root of the problem, and that it would be best of you could guarantee it's off. I don't know about using Apache directives to do it - might a local php.ini be more reliable?
starsky
Posts: 15
Comment
Need a little help
Reply #12 on : Fri February 19, 2010, 00:28:22
Sorry for posting something irrelevant but I would like to find out how to show the post author's name along with the blog post... Any help would be nice :)
bodmin
Posts: 1
Comment
Author's name with blog post
Reply #13 on : Fri February 19, 2010, 13:59:55
I think the AuthorTimestamp snippet (in the MODx site's Extras) will do what you want:

modxcms.com/extras/package/25
starsky
Posts: 15
Comment
Re:Author's name with blog post
Reply #14 on : Tue February 23, 2010, 00:23:48
Thanks you so much! I will try to integrate it to the blog.

I would like to ask again some help on how to strip those escaped quotes. Magic Quotes are turned on in the server but I don't have access to this php.ini thing. I googled a workaround about adding this line of code but I have no idea where to put this. :( Any help will be greatly appreciated.

<?php
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
?>
kp52
Posts: 6
Comment
More magic quotes
Reply #15 on : Tue February 23, 2010, 09:19:56
@starsky: are you sure you can't add your own custom php.ini in the root of your site? On my host, the phpinfo() output includes:
Configuration File (php.ini) Path /home/<account>/php.ini
so I could set magic_quotes_gpc to OFF in there if I needed to.
If you can edit your own .htaccess file, the other method mentioned in the PHP manual entry on magic quotes might work for you.
I'd say fiddling with slashes in the data is very much a last resort, but if I had to do it, I'd start by adapting the code above to work on the $fields array near the top of the main include file, as all the relevant input values are copied to it and used from there. But see earlier comments on jelly and walls.
Last Edit: February 23, 2010, 09:20:40 by kp52  
Tom
Posts: 15
Comment
Multiple usages possible??
Reply #16 on : Tue February 23, 2010, 19:01:35
I'd like to try using pkBlog twice for two different site sections, with quite different content, actually probably 3 different sections.

How would I do this, please?? -- copy in and rename 3 different instances of the blog files into the standard assets etc. folders?? What other values in your code would require changing??

Also, is it possible to un-publish blog entries when one wants to do so??

Thank you, Tom
kp52
Posts: 6
Comment
Multiple use
Reply #17 on : Wed February 24, 2010, 10:49:27
Hi Tom,
yes, you can have several sections, you just need to keep your organization clear. I've responded at length in the MODx forums (http://modxcms.com/forums/index.php/topic,38685.0.html)
starsky
Posts: 15
Comment
Re:More magic quotes
Reply #18 on : Fri February 26, 2010, 09:07:44
Thanks for the BIG help! I was able to disable it via .htaccess.

I would like to ask something again though. How do I add categories in the blog?
kp52
Posts: 6
Comment
Blog categories
Reply #19 on : Sun February 28, 2010, 22:07:56
Hmmm... a question of definitions arises here, methinks. I take it you want to have some kind of hierarchy, with predefined broad categories to classify articles that may have a variety of lower-level (maybe cross-category) tags? I've only done one or the other at a time, so Ditto "tags" have met my needs. I should think you could set up something to handle a second tag-style options TV and use Ditto's filter mechanisms to complement the tagging currently allowed for. I'll bear it in mind for the future, sorry I couldn't be more precise at the moment.
starsky
Posts: 15
Comment
Re: Blog categories
Reply #20 on : Thu March 04, 2010, 03:52:08
Ummm... I'm thinking about having, say, a category like 'Fishing' where all posts about fishing will go. It's just a simple category system (a cross-category would be an overkill :D) for better organization.

Thanks for the immediate reply!
dimi
Posts: 15
Comment
quotes issue
Reply #21 on : Tue April 20, 2010, 09:09:33
Hi,

nothing seems to work for me about the quotes, htaccess gives server error 500 and php.ini is not an option, isn't there an option to add php code somewhere?

i hope someone is able to help me!

thanks!
sottwell
Posts: 15
Comment
escaped quotes
Reply #22 on : Sat April 24, 2010, 20:47:45
Try putting a file named php.ini in your site's root directory with just this one line:

magic_quotes_gpc = off

Put another copy of the same php.ini file in your manager directory. These files are not inherited; you need to put one in every directory where a .php file is run. In our case, it's the site root for the main index.php, and the manager for the manager's index.php.

http://php.net/manual/en/security.magicquotes.disabling.php

Write a comment

  • Required fields are marked with *.

If you have trouble reading the code, click on the code itself to generate a new random code.