We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    =)...ok, I did revert the "alias" thing^^...works fine without it...(saving changes to an existing resource and be redirected to it after saving...).

    I have two other questions:
    I added the &cancelid param and gave it an integer value, but the cancel button doesn’t redirect me to this page, not when I edit an exsisting resource (and cancel from there --> this will redirect me to the page I wanted to edit, which is fine) nor when I create a new one (and cancel from there --> this will just give me the blank /newspublisher.html page, with no form, just the template without any content...I thought from there it would redirect me to the cancelid? Am I wrong?)

    [EDIT START] OK, I got it...the param &cancelid=`int` needs to be camelcased ie. &cancelId=`int`, I think this shouold be correced in the snippet comments and also in your tutorial =) or you define something in this direction in the snippet:

    $cancelId = empty($scriptProperties['cancelid']) ? $defaultDocIdOrSomethingElse : $scriptProperties['cancelid'];


    The problem I had now was that the cancel button was always redirecting to the defined ressource, but I just wanted a redirection if creating a new ressource is canceled, in the case the editing affects an existing ressource and I cancel, I would like to be redirected to this ressource again, more like a "oh shit, not this one, go back"-behavior =D, so I had another look into the code and added the following second condition to the if statement in the NewsPublisher-Snippet @line 122:
    if (!empty ($cancelId) && $_POST['np_existing'] == '') {


    I’m still a biiig noob in PHP so I couldn’t get access to the "existing"-thing from the newspublisher.class.php file, not via $this->existing (Fatal error) nor via $np->existing (no acces to protected function) so I did it the ugly way^^...What I also noticed is, that the np_existing hidden input value isn’t set when no form is submitted (logically =D), so a ’false’ doesn’t help...am I missing something or is it only possible to create a new ressource when calling the NewsPublisher-Ressource directly with http://www.domain.tld/newspublisher.html?? If this is the case, how about another button (maybe below the "Edit" Button) which says "Create"? Just to make the UI a little more comfortable...
    [EDIT END]

    A similar problem occurs when I save a new created ressource...I just see an empty page (no content, but with the template) instead of the new ressource displayed (what I expected =D).

    [EDIT START]I found the param &postid=`int` (which is missing in the tutorial too =D), so I gained a bit of control, but not as I wanted, because now it always redirects me to the defined id and not the the newly saved (existing) ressource...I only want to be redirected to the NEW created ressource instead of being redirected to the emtpy /newspublisher.html page...I tried around, but with no success...any ideas how to solve this?
    [EDIT END]

    Another "issue" which is maybe not that easy to solve is the "parent"-resource field which is displayed as a text-field for an integer. Can you think of a way to give the user a selection of what’s available (best would be the title of the ressources)? Even I as the developer of the site do not know which container has which ID...this is impossible, so I have to go into the backend anyways to look up the parent ID...

    The "wrong template"-issue on installation was my fault! Had nothing to do with the transport package which does not create the NewsPublisher-Ressource (this one I had to create manually [which is definitly ok! by the side], according to your tutorial). In one of my brain-fart-moments (they show up often as it seems =P) I changed the template of the NewsPublisher-Document to 0 (blank) which has the effect, that there’s no <head>-tag which line 362 needs (I think so) to inject the newspublisher css...
      • 3749
      • 24,544 Posts
      I had a little trouble following all that. wink

      The cancelid issue was, indeed, a bug in the code. It should be cancelid (all lowercase). When you upgrade to the next version, you’ll have to change it back to cancelid in the tag (or change it back now, and change the two references to $cancelId to $cancelid in the code).

      NP is supposed to forward you to the newly created resource after creating a new doc. It did for me when I tested it last, but I haven’t tried it in MODX 2.1 yet so that could be an issue. I’ll try to look into it when 2.1-pl is out (hopefully next week).

      I’d strongly recommend not messing with $this->existing because that’s how NP knows whether it’s a new doc or not (and new docs don’t actually have an ID until they are saved, so it’s not available for them anyway). Changing it yourself will almost certainly create bugs.

      On the cancel button, I’m not clear on what you want. It may help to know that if you don’t send that parameter at all, the cancel button will take you to the previous page (like the back button in your browser) -- assuming that HTTP_REFERER is set by the server (most do, some don’t).

      It’s also possible to have two different NewsPublisher resources, one for editing existing docs and one for creating new ones (each with it’s own &cancelid). I haven’t tried it, but it ought to work. I’m not sure if that would solve your problem or not.

      Here’s something that also might work for you. Duplicate the NpEditThisButton snippet. Call it NpCreateNewButton. Delete the two hidden fields in the form and change the &buttonCaption property in the tag to "Create New." Put a tag for that new snippet below the NPEditThisButton tag. That should let you create a new doc from any page (again -- untested).

      Thanks for all the feedback and for finding the cancelid bug. smiley


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 27408
        • 33 Posts
        I can’t seem to download the new version of Newspublisher ((1.1.0-pl1). The download link in the extra’s section is dead, and the new version is not on Github (yet). I see no support topic either...
          • 3749
          • 24,544 Posts
          Quote from: Sitethief at Jun 07, 2011, 03:40 AM

          I can’t seem to download the new version of Newspublisher ((1.1.0-pl1). The download link in the extra’s section is dead, and the new version is not on Github (yet). I see no support topic either...

          I see it in Package Manager "Download Extras" in MODX 2.1.1-pl

          and also here: http://modx.com/extras/package/newspublisher (Be sure you’re on the Revolution tab.)
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 34416
            • 10 Posts
            Here is the great tutorial how to use NewsPublisher to Create/Edit resources from frontend (thanks to Bob Ray). And how I’ve pointed here, there are another good way to do such simple thing like to make easy creating and editing resources from frontend (thanks to Bruno).
            First way with NewsPublisher is easier as I understood when was pressing "Edit"-button first time. But I can’t find any way to check my frontend field’s content like in FormIt, where it’s quite easy with Validators. May be of course there is a way and it’s me who can’t spot it smiley So the question is how to validate fields (min-max length, min-max value, is string, is number and so on)?

            FirstAfter: This answer was like a blow. It seems that my task can’t be solved by NewsPublisher. Or it can?
              • 3749
              • 24,544 Posts
              Sorry, no built-in validators for NewsPublisher at this point. You can, however, add JS validation to your Tpl chunks, which is probably a better way of doing it anyway. You’ll be limited somewhat on the TVs in that all TVs of a certain type will have the same validation unless your JS gets a little complicated.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36602
                • 8 Posts
                I'm having a problem considering an <iframe> tag. Newspublisher just won't save the tag. I have a specified template variable for Youtube videos, which should save the embed code, but Newspublisher just saves the field empty. When done from backend, the process goes through just fine. Tried every input/output option possible but to no avail. Please halp!