We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43509
    • 24 Posts
    Hi,
    I am using the NewsPublisher extra to edit existing resources... and it works as expected.
    But I would also like to create new resources. It is not clear to me how to acomplish that... the snippet seems always connected to the page id where I call it, so I just can edit existing resources and not create news.

    Note: I am using NewsPublisher with Articles, and I would like to create new posts.
    Also: is it possible to have multiple NewsPublisher edit buttons in the page with list Articles' posts? I mean: in the postRow template.

    And another question: I would like to edit the content through rich text editor. I am using "&initrte=`1`" e "&rtcontent=`1`" in my snippet, but no rich text editor appearing!

    Thank you for your help! [ed. note: matpiaz last edited this post 13 years, 4 months ago.]
      • 3109 ☆ A M B ☆
      • 894 Posts
      Apparently NewsPublisher has been updated to work with Articles so you need to create a Resource with your NewsPublisher snippet with the properties you want to modify using Bobs instructions here

      Good Luck.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 43509
        • 24 Posts
        Quote from: benmarte at May 14, 2013, 07:05 AM
        Apparently NewsPublisher has been updated to work with Articles so you need to create a Resource with your NewsPublisher snippet with the properties you want to modify using Bobs instructions here

        Good Luck.


        Yes, I read the instructions, but still it's not clear to me how to "create" new content, and all the other questions I still have....
          • 25803 ☆ A M B ☆
          • 721 Posts
          We have people go to a page that has links to create documents in specific places, ie:

          <p><a href="edit/edit-blog.html">Add New Blog Entry</a></p>


          The edit-blog document then contains code like this:

          [[!NewsPublisher?
          &initrte=`1`
          &rtcontent=`1`
          &initdatepicker=`1`
          &textmaxlength=`1000`
          &show=`[[$commonfields]],[[$blogfields]]`
          &parentid=`88`
          &template=`Blog Entry`
          &published=`1`
          ]]
          


          Where the chunks commonfields and blogfields are like this:

          $commonfields

          pagetitle,longtitle,alias,introtext,menutitle,hidemenu,menuindex,content,pub_date,seodescription,seokeywords,seorobots


          $blogfields

          blogauthor,blogauthorimage


          This was before Articles of course.

          I think the key fields in the Newspublisher call are:

          &parentid=`88`
          &template=`Blog Entry`
          &published=`1`


          But we haven't updated our version in awhile so this info may be out of date.
            • 43509
            • 24 Posts
            Well, your idea is good: maybe I could use your trick adapted!

            I could check if the user is logged in through "If" snippet or MODx output modifiers maybe.
            If the user is logged in I will display a link similar to
            <a href="edit/edit-blog.html">Add New Blog Entry</a>
            which in turn points to a document which implements the "NewsPublisher" snippet.

            I will give it a try and let you know!
              • 3109 ☆ A M B ☆
              • 894 Posts
              Make sure you use the articles parameters otherwise it will not add the new articles to the article container and they can't be seen in the manager unless you use the search function in the file tree.

              &parentid — The ID of the Articles container
              &template — The ID of the blog post template
              &classkey — `Article`
              &hidemenu — `1`
              
                Benjamin Marte
                Interactive Media Developer
                Follow Me on Twitter | Visit my site | Learn MODX
                • 43509
                • 24 Posts
                Surfing on the idea suggested by rx2, here it is my (so far working) solution.

                1) I wrote the snippet "checkLogin" to chek login status:
                $user = $modx->getLoginUserName();
                $logged;
                
                if ($user) { 
                	$logged = 1;
                }
                else{
                    $logged = 0;
                }
                
                return $logged;
                


                2) Then, in the chunk where I want to display content login related, I check the login status through MODx output modifiers applied to "checkLogin" snippet (here, for instance, I show a link to add a new post to the blog only if the user is logged in):
                [[!checkLogin:is=`1`:then=`<a href="[[~245]]">Write new post</a>`:else=``]]
                


                Or, if you prefer, you may also test it through a call to the "If" snippet:
                [[!If?
                   &subject=`[[!checkLogin]]`
                   &operator=`EQ`
                   &operand=`1`
                   &then=`<a href="[[~245]]">Write new post</a>`
                   &else=``
                ]]
                


                3) Where "[[~245]]" is the page containing the "NewsPublisher" snippet, properly parametrized:
                [[!NewsPublisher?
                    &show=`pagetitle,published,introtext,content`
                    &initrte=`1`
                    &initdatepicker=`1`
                    &rtcontent=`1`
                    &rtsummary=`1`
                    &parentid=`67` 
                    &template=`12` 
                    &classkey=`Article` 
                    &hidemenu=`1`
                ]] 
                
                  • 25803 ☆ A M B ☆
                  • 721 Posts
                  You could also use the Personalize snippet:
                  [[!Personalize?
                      &yesChunk=`createNewPost`
                      &noChunk=``
                  ]]


                  Where you'd have a chunk called createNewPost with this in it:

                  <a href="[[~245]]">Write new post</a>