We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16278
    • 928 Posts
    I think some PHP/MODx issues are interfering here:
    1). In the blog post, the single and double quotes are getting escaped. For example She said "stop." turns into, she said \"stop.\"
    This is down to PHP "magic quotes" being enabled. It will seriously intefere with any form processing, and is highly undesirable in any up-to-date PHP setup. If you have access to your php.ini file, insert the line
    magic_quotes_gpc = Off
    to disable it. There are quite a few threads on this issue in the forum, including other ways to switch it off if you are not able to use php.ini.

    2). Posts that were made prior to installing PubKit show a creation date of 1969.
    If you’re using pkDate as the item date, and it’s empty, you get a zero result as the timestamp, or 0000 on 1st Jan 1970 (slipping back to 2300 31 Dec 1969 because of DST). I haven’t tried it, but if you set a default date for pkDate that might give you something more credible; or you may be able to use the DocManager module to set some values in the TV en masse.

    3). I am unable to get dates from either [+pub_date:dateIfSet=`%d-%m-%y`+] or [+pkDateTo:dateIfSet=`%d-%m-%y`+]
    Are you sure you have named the PHx modifier snippet correctly (phx:dateIfSet)? What output do you get with an unmodified placeholder such as [+pub_date+], or the built-in PHx modifier [+pub_date:date=`%d-%m-%y`+]?

    4). In the document tree, when logged in as Administrator, I am unable to look at any of the new documents

    Not sure about this, but it sounds like a MODx installation issue - try searching for the error message.

    5). Will there be an option in the future to edit and re-save a post without re-publishing the post (making a duplicate)?
    This should be the standard action already! Opening the page containing your PubKit call (e.g. post-edit.html) with ?docId=99&command=edit as the query string or equivalent POST values should mean you are reediting document 99. This is what the hyperlink from the management list should do. I use it all the time, because I’m always spotting typos just after publishing something.

    The risk of duplicates with PubKit as it stands is when you are in the Preview screen, if you use the browser’s Back function instead of the Edit button.

    Thanks for the feedback!
    smiley KP
      • 16278
      • 928 Posts
      PubKit 0.6.4 is now available from the original post of this topic, and from the Pogwatch site. The changelog has also been posted.

      Bug fixed: automatic unpublication after expiry date now works

      Other changes:
      - snippet parameters are now available to the class functions via the $fields array
      - ordering of resources using menuindex can now be handled (pkBlog feature that fell off the cart earlier)

      Documentation is the same as 0.6.3. For the time being, that is.
      smiley KP


        • 16278
        • 928 Posts
        @pixelstation: sorry I didn’t have time to look at this earlier. Here’s what I came up with, taking the task as:

        - record the (full) name of the original author of an item in a TV belonging to it
        - display the name in the input form when re-editing, if required

        My TV was a simple Text type called blogAuthor attached to the relevant template. There are loops in the original document Save code in pubKit.inc.php (lines 194-202 in PubKit 0.6.4) and retrieve-for-editing code (lines 313-317) that transfer all the TVs to and from the document object as long as their name and format don’t need to change. hence no need for any processing as custom fields - that stuff is only needed when the data format or the name of your form field is different from what is stored.

        So my special class (called newsItem in my test) looks like this:
        <?php
        class newsItem extends Resource
        {
        	public $defaultDate; // set using function in constructor
        
        	public $tvs = array(
        		'pkDate'=>NULL,
        		'pkDateTo'=>NULL,
        		'blogAuthor' =>NULL
        		);
        
        	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->tvs['pkPreviewFlag'] = (isset($fields['preview'])) ? 1:0;
        	if (empty($pid)) {
        		$this->tvs['blogAuthor'] = $_SESSION['webFullname'];
        	} else {
        		global $modx;
        		$author = $modx->getTemplateVar('blogAuthor', 'id', $pid);
        		$this->tvs['blogAuthor'] = $author['value'];
        	}
        	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;
        }
        
        }
        ?>

        The if/else is needed in the constructor function so that the author name is only recorded when the item is new (has no ID). When re-edited, you have to retrieve the name and insert it into the tvs array, otherwise the null value in the definition zaps it when next saved.

        The name is now in the $fields array when re-editing, so you can display it in the form with the placeholder [+blogAuthor+] if required.
        smiley KP
          • 23510
          • 168 Posts
          I appreciate it KP52, will check this out again.
            • 12661
            • 18 Posts
            KP,

            Thank you for such a quick and detailed response. I added a php.ini to my MODx root with:

            magic_quotes_gpc = off


            This fixed #1, #4 and some other abnormal behavior. For example I noticed that the magic quotes turned phx:dateIfSet and phx:statusFormat into phx~dateIfSet and phx~statusFormat.

            I am still troubleshooting #3.

            Do you have a demo account that shows how you setup the back-end to PubKit? It would be helpful to some of us greener MODx users to see the power of what can be done.

            Thanks again for the help,
            Ian
              • 3722
              • 171 Posts
              I am having problems with adding an item for a News item.
              When I preview the news-manage page and click "add item" I get sent to my home page and my browser says I am at "/admin/news-edit".
              When I preview my news-edit page it says "You do not have permission to post items here".

              I think it may be an issue with my file layout and Ditto calls to the correct page.

              My file are setup like this:
              News (9)
              --First article (13)
              --Second article (14)
              Admin (41)
              --News manage page (38)
              --News edit page (38)

              My Ditto call on the manage page only shows the "add item" page when the call is this "[!Ditto?parents=`37`"
              If I set it to `9` or `38` I get the MODx parse errors.

              Thanks for any help
              BG66

                • 1892
                • 82 Posts
                Quote from: BobbyG66 at Jul 15, 2010, 12:31 PM

                I am having problems with adding an item for a News item.
                When I preview the news-manage page and click "add item" I get sent to my home page and my browser says I am at "/admin/news-edit".
                When I preview my news-edit page it says "You do not have permission to post items here".

                I think it may be an issue with my file layout and Ditto calls to the correct page.

                My Ditto call on the manage page only shows the "add item" page when the call is this "[!Ditto?parents=`37`"
                If I set it to `9` or `38` I get the MODx parse errors.


                Hi, I’ve just started with PubKit so I’m still on the learning curve as well, however there are a couple of things to mention.

                First I presume your news manage page is actually id = 37 (you’ve listed 2 page 38s in your structure.), otherwise I don’t see a problem with your layout.
                On the news manage page the ditto call should be parents=`9` as this defines the start id for the news articles. Presumably this gives you the error messages.

                One thing to check is the news manage page, near the top there is the code for adding a new item. The string in action="", must reference the friendly url for your news edit page id 38. On my setup I’m using it for Area group reports so mine looks like this.
                <form method="post" action="/welcome/area-reports/area-edit" id="addItem">


                For the news edit page permissions in your pubKit call do you have a parameter &canPost= defined? In my setup I define a web user group here
                &canPost=`full member`

                So only people logged in and members of this web user group will actually get permission to add entries. According to the documentation if you leave it blank then anyone can post. What do you have in your news edit page?

                I hope this helps

                Adrian
                  • 3722
                  • 171 Posts
                  Thanks apcherry,

                  1) Typo on my part when posting. My News Edit page is (37).

                  2) My news manage page (38) is this:
                  <form method="post" action="../admin/news-edit" id="addItem"> <input type="submit" value="Add item" />
                  </form>
                  <div>
                  <table>
                  <thead><tr>
                  <th colspan="2">Item and status</th><th>Date</th><th>Publish</th>
                  <th>To</th></tr></thead>
                  <tbody>
                  [!Ditto?parents=`9` &tpl=`news.manage.tpl` &showPublishedOnly=`0` &orderBy=`pkDate DESC,editedon DESC` &extenders=`pkStatus` &tagData=`acNews` &debug=`0`!]
                  </tbody>
                  </table>
                  </div>


                  My News Edit page (37) is this:
                  [!PubKit?class=`post` &folder=`9` &template=`` &tags=`acNews` &rtcontent=`pkRichContent` &formtpl=`news.input.tpl` &tagFormat=`chk` &canPost=`editor` &debug=`0`!]


                  When changing to "folder=`9`" I get a MODx Parse Error.

                  3) When previewing my News Edit page, the details input box is not shown.
                  I tracked it down through the TV [*pkRichContent*]
                  The default value is [+newsBody+]
                  I do not have a TV by that name and do not see it referenced in the docs anywhere.
                  What are the parameters for that TV?
                    • 1892
                    • 82 Posts
                    Quote from: BobbyG66 at Jul 18, 2010, 02:11 PM


                    2) My news manage page (38) is this:
                    <form method="post" action="../admin/news-edit" id="addItem"> <input type="submit" value="Add item" />
                    

                    Hi, I don’t think you need the .. at the beginning of the action - I presume that the URL alias for your Admin page(41) is admin and your news-edit page (38) URL alias is news-edit then I’d expect the following to work
                    <form method="post" action="/admin/news-edit" id="addItem"> <input type="submit" value="Add item" />
                    


                    Quote from: BobbyG66 at Jul 18, 2010, 02:11 PM

                    My News Edit page (37) is this:
                    [!PubKit?class=`post` &folder=`9` &template=`` &tags=`acNews` &rtcontent=`pkRichContent` &formtpl=`news.input.tpl` &tagFormat=`chk` &canPost=`editor` &debug=`0`!]


                    When changing to "folder=`9`" I get a MODx Parse Error.
                    Does the MODx Parse error give you any clues?

                    Quote from: BobbyG66 at Jul 18, 2010, 02:11 PM

                    3) When previewing my News Edit page, the details input box is not shown.
                    I tracked it down through the TV [*pkRichContent*]
                    The default value is [+newsBody+]
                    I do not have a TV by that name and do not see it referenced in the docs anywhere.
                    What are the parameters for that TV?
                    Not sure about this - actually I don’t have a TV called newsBody and it still works for me. I presume this is just a default template to stick in the news edit page when creating a new item. I suppose if you want posters to follow a certain format then you can use this field.

                    What settings have you used for for pkRichContent? On my setup the width at 100% was too wide for my template and it flowed off the bottom. I reduced the width to 60% and it slotted into place.

                    Does the rest of the add item form appear - title, intro, buttons etc? As defined in your news.input.tpl chunk. Which should include the details section as follows.

                    <div class="row">
                    <span class="edLabel"><label for="detail">Details</label></span>
                    <span class="edField" id="detail">[*pkRichContent*]</span>
                    </div>


                    Sorry I don’t know what else to suggest, I’ve only just started using PubKit so I’m just going off what has worked for me - so no guarantee that I’m doing it correctly.
                    Regards

                    Adrian

                      • 3722
                      • 171 Posts
                      Adrian,

                      Thanks for the feedback.

                      I removed the ".." in front of "../admin/news-edit".
                      I was trying that out, but made no difference in or out.

                      MODx Parse Error:
                      I removed "editedon DESC" from:
                      [!Ditto?parents=`156` &tpl=`news.manage.tpl` &showPublishedOnly=`0` &orderBy=`pkDate DESC,editedon DESC` &extenders=`pkStatus` &tagData=`acNews` &debug=`0`!]

                      and that got rid of the Parse Error.

                      I played around with the settings for "pkRichContent" with no effects. Everything shows up except for the "Details" section.

                      I will keep messing around with it.
                      BG66