We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16278
    • 928 Posts
    At last I have managed to put together a package and some documentation for PubKit, a snippet for creating and publishing MODx Evolution documents using front-end web page forms. Full details and download are available at http://www.pogwatch.com/pubkit.html, or you can download from here with less documentation.

    PubKit is now published in the Extras. Please raise further questions in its support thread.

    PubKit goes beyond the capabilities of its predecessor pkBlog. Key features include:
    - PHP classes define types of item, so a variety of formats can be defined without fiddling with the core code;
    - classes permit you to create specialized methods and properties for specific types of item, e.g. data validation;
    - possibility of using custom tables as well as MODx resources as the basis of your item (you still need to create the tables with phpMyAdmin or a MODx module);
    - update any built-in or custom template variable using the snippet (in the sample files, set or clear the published field or an archive flag from the management list);
    - hooks to use different language files for prompts and error messages

    I know there’s still plenty that could be improved - including better safeguards against item duplication (if you use Back from the preview), and simple arrangements to cater for multiple-author blogs. And there are plenty of comments in the code starting "TO DO...". All the same, I hope you’ll find it worth a try, and let me know how you get on.
    cool KP
    • Great! I’ve been looking forward to this. PKBlog has been very useful, but there’s so many hard-coded presumptions in it (like required fields) that I’ve had to modify tongue
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 1892
        • 82 Posts
        Hi,

        It looks very promising. I’m trying to set up a site where various area groups can post the latest news from their neck of the woods. Most of them would be put off by the modx backend manager for creating new reports. A simple front end web page for them to stick in a few updates would be ideal - is this something that PubKit could do?

        I can edit the backend code myself but I’m trying to get something easy for the non-technical users could be comfortable with. Is their a demo site so that I could see how PubKit works for adding new articles?

        Regards

        Adrian
        • I haven’t had the opportunity to look at PubKit, but I have used PubKitBlog for this. We set up an unpublished page to act as the front-end Manager (logged-in manager users can see unpublished pages) and set its ID as the login home ID for the Manager users involved. We also added that page as a custom link in QuickManager. That front-end Manager page had links to the various resources (in an unpublished Tools container/document) where a customized PubKitBlog was installed for editing/creating the relevant resources. Between that and using Jot (or a customized hack of it I call Notes) for simpler lists of things (like events, FAQ question/answer lists, or restaurant menus) the client never needs to see the back-end at all.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 1892
            • 82 Posts
            Thanks for the info - I’ll have a deeper look at PubKit then.
            Adrian
              • 16278
              • 928 Posts
              A simple front end web page for them to stick in a few updates
              was my starting point, too!

              I’ve hacked pkBlog around for various purposes, but you need to get to know the main entry points and places where data changes to do that. The main point of PubKit is to make customization separate from the core processing loop, consigning site-specific aspects to PHP classes when they’re not catered for by parameters. This approach has also made it possible to handle custom tables in a similar way, from a single snippet, though with different include files for the CRUD business.

              Quite a few queries about PubKitBlog have concerned multiple-user scenarios (I haven’t had to provide any myself as yet). I’m sure the necessary arrangements can be made, if you get a good idea early on as to likely numbers of users, and how segregated you need them to be when it comes to the control panel (management screen) - should users be able to view others’ lists and publish/depublish/update/delete etc. others’ posts?

              Incidentally, publish/depublish from the management screen is another frequent request for pkBlog, easy to achieve in PubKit.

              A small update to PubKit is in the pipeline - main change fixes a bug with event listings, so that single-day events automatically get the next day as depublication date. It also adds possibility of ranking resource-based items by menuindex for ordered lists.

              smiley KP
                • 1892
                • 82 Posts
                Quote from: kp52 at Jun 15, 2010, 12:39 PM


                Quite a few queries about PubKitBlog have concerned multiple-user scenarios (I haven’t had to provide any myself as yet). I’m sure the necessary arrangements can be made, if you get a good idea early on as to likely numbers of users, and how segregated you need them to be when it comes to the control panel (management screen) - should users be able to view others’ lists and publish/depublish/update/delete etc. others’ posts?

                Incidentally, publish/depublish from the management screen is another frequent request for pkBlog, easy to achieve in PubKit.

                Thanks for the info - it looks promising. We’re a small but happy and social group of modellers just posting updates from around the country. We have area group representatives who I envisage will do the updates so probably no more than a dozen users adding entries. Each will probably just look after their own postings but I’ve often found that the game plan has to change once you let the users loose on the system! So who knows.

                Never considered the depublish option before but I can see how that can be useful.

                Regards

                Adrian
                  • 26931
                  • 2,314 Posts
                  Hey Keith,

                  downloaded the package ... and WOW! you’ve put a lot of hard work into it shocked just wanted to say thank you!! // need to play with it. that’s a lot of code in there! smiley

                  pagination works via Ditto? if so, also with custom DB tables? ...and this is for WebUsers/Groups, right?
                    • 23510
                    • 168 Posts
                    Hi kp52

                    Ok I have a few questions. Im trying to setup a blog but for multiple webusers to have their own blog items. I therefore need to be able to store the name of the author i.e. username of the webuser that is logged in. I made these changes to postblog.class.inc.php (a copy of post.class.inc.php) however it is not working. I was trying to follow the documentation with exactly what I need to do for custom fields and was not particularly understanding it.

                    <?php
                    class Postblog extends Resource
                    {
                    	public $defaultDate; // set using function in constructor
                           public $authorPost; // <-- added line
                    
                    	public $tvs = array(
                    		'pkDate'=>NULL,
                    		'pkDateTo'=>NULL,
                                  'authorPost'=>NULL // <-- added line
                    		);
                    
                    	public $validate = array(
                    		'pagetitle'=>'string||Req||title',
                    		'longtitle'=>'string||Req||postHeadline',
                    		'tvpkRichContent'=>'string||Req||postContent',
                    		'displayDate'=>'date||Req||displayDate',
                    		'displayFrom'=>'date||Opt||fromDate',
                    		'displayTo'=>'date||Opt||toDate'
                    		);
                    
                    function __construct($pid, $fields, $lang) {
                    	$this->defaultDate = strftime($lang['dateFormat']);
                           $this->authorPost = $_SESSION['webShortname'];     // <-- added line
                    	$this->tvs['pkPreviewFlag'] = (isset($fields['preview'])) ? 1:0;
                    	parent::__construct($pid, $fields, $lang);
                    }
                    
                    function CustomFields($fields, $doc) {
                    	$customFields = array();
                    
                        $customFields['displayDate'] = strftime($this->lang['dateFormat'], strtotime($fields['pkDate']));
                        $customFields['displayTo']   = ($fields['pkDateTo'] > 0) ?
                    		strftime($this->lang['dateFormat'], strtotime($fields['pkDateTo'])) : "";
                        $customFields['displayFrom'] = ($doc->Get('pub_date') > 0) ?
                    		strftime($this->lang['dateFormat'], $doc->Get('pub_date')) : "";
                    
                    	return $customFields;
                    }
                    
                    }
                    ?>
                    
                      • 12661
                      • 18 Posts
                      This looks like a great package. I carefully installed all the TV’s, Snippets, Chunks, etc. for the basic blog page demo. I am getting the basic functionality but there are a couple things that crop up.

                      1). In the blog post, the single and double quotes are getting escaped. For example She said "stop." turns into, she said \"stop.\"

                      2). Posts that were made prior to installing PubKit show a creation date of 1969 (not a big deal, just an observation).

                      3). I am unable to get dates from either [+pub_date:dateIfSet=`%d-%m-%y`+] or [+pkDateTo:dateIfSet=`%d-%m-%y`+], even when set when the post was published.

                      4). In the document tree, when logged in as Administrator, I am unable to look at any of the new documents, created from PubKit, from the backend. I am told "You don’t have enough privileges for this action!"

                      5). Will there be an option in the future to edit and re-save a post without re-publishing the post (making a duplicate)?

                      Suggestions?

                      Thanks for all the work, Ian