We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Hi, just engaged myself with the NewsPublisher. In the standard call you have to set a parent folder where you want to post the document. This is not very flexible if you have several News/Blog categories. Instead of setting up a NewsPublish call for every category (folder), I wanted a more usable solution. And here it is:

    First, create a plugin "referer" with this content:

    $_SESSION['referrer']= $modx->documentObject['id'];


    and activate it for the system event "OnLoadWebDocument".

    Then create a snippet "referer" with this content:

    $output = $modx->getParent($_SESSION['referrer'],1,'id');
    return $output['id'];


    Create a document "Publish News" (or similar), restricted to the web user group which should be able to publish and put in the NewsPublish call: (for example):

    [!NewsPublisher? &folder=`[!referer!]` &canpost=`blog admin` &formtpl=`blogform` &=`tvblogcontent`!]


    How to set up newspublisher is described here, thanks to Jason for this hint.

    What it does:

    If you want to publish directly from your site, just surf to a document in the category where you want to publish a new one. If you have the permission to post a new entry, you should see the menu entry "Publish News" from above in the menu. If you click that, the form for a new entry is shown and automatically set to the category from where you hit the menu entry "Publish News".

    Example:

    You have a news section with 5 categories: Hardware, Software, CMS, PHP, AJAX. You want your news authors not to enter the manager and want to use the NewsPublisher. But you don´t want to create five calls for the NewsPublisher for every category. So use the solution above. The author who for example wants to publish in "CMS" only has to surf to a news entry in the category "CMS". Then click on "Publish News" and it will automatically show the form for the entry and will save it in the category "CMS".

    How it works:

    The plugin writes the actual document id in the _session array. The snippet reads this and gives back the parent of the id of the referer page. This is used to call the NewsPublisher snippet and give it the parent id of the referred document.

    Hope this is understandable smiley

    Regards,
    Marc


      • 25663 MODX Staff
      • 12,272 Posts
      Marc, brilliant! laugh
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 2762
        • 1,198 Posts
        Thanks a lot Marc! it’s a very needed feature!! great works
          Free MODx Graphic resources and Templates www.tattoocms.it
          -----------------------------------------------------

          MODx IT  www.modx.it
          -----------------------------------------------------

          bubuna.com - Web & Multimedia Design
          • 17883
          • 1,039 Posts
          Thanks you two. But i just realised that it doesn´t work that way sad

          Problem is that after the publishing entry the snippet is called again for processing the data and then the referrer isn´t correct. I have to find a way to pass the referrer variable through the publishing form, but all my effords with a hidden input field don´t work. There are also some caching issues, so that I have to think about the whole concept and will post again when I found a solution for that.

          Marc
            • 19220
            • 26 Posts
            Any progress on this? I don’t know anything, but this seems like the right way to go, and I’d like to use it.

            Thanks,

            -michael
              • 6470
              • 69 Posts
              Quote from: MadeMyDay at Apr 14, 2006, 11:09 AM

              Thanks you two. But i just realised that it doesn´t work that way sad

              Problem is that after the publishing entry the snippet is called again for processing the data and then the referrer isn´t correct. I have to find a way to pass the referrer variable through the publishing form, but all my effords with a hidden input field don´t work. There are also some caching issues, so that I have to think about the whole concept and will post again when I found a solution for that.

              Marc

              I think I found kind of a solution


              Make a plugin PrevPage [ I use it to return previous page id]
              $_SESSION['referrer2']= $_SESSION['referrer'];
              $_SESSION['referrer']=$modx->documentIdentifier;
              

              check in events
              OnLoadWebDocument
              OnParseDocument

              ---------------------
              Make a snippet PrevPage
              <?php
              $output=$_SESSION['referrer2'];
              
              return $output;
              ?>
              

              Call uncached
              --------------------------

              Onother version of plugin do not require any snippets
              It fills two placeholder
              [+idi+] current ID [+holder+] previous ID

              It may used for return to prev page link
              or
              [!WebLogin? &tpl=`FormLogin` &loginhomeid=`[+holder+]` &debug=`1`&logouthomeid=`[+holder+]`!] I have a form call on a separate page
              or
              [!NewsPublisher? &amp;folder=`[+holder+]` &amp;canpost=`Blog Admins` &amp;formtpl=`FormArticle` &amp;makefolder=`1` &amp;rtcontent=`tvblogContent`&amp;clearcache=`1`!]

              $Holder=$modx -> getPlaceholder('idi');
              $modx -> setPlaceholder('holder', $Holder);
              
              $sentvariable =$_SESSION['referrer2'];
              
              $modx -> setPlaceholder('idi', $sentvariable);
              $_SESSION['referrer2']=$modx->documentIdentifier;

              Events
              OnLoadWebDocument OnParseDocument