We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32847
    • 171 Posts
    I don’t know if I used the right way but I found something to do what I want
    However, I have got a small problem

    Just a piece of my little code, I will post all later

    $doc = $modx->getDocument($id);
    return $doc['createdon'];
    


    I would like to understand why this works only if published is set to 1
    With unpublish document (published=0), nothing append, I haven’t my createdon date whereas there is one in the database huh

    Thanks
      • 6726
      • 7,075 Posts
      Been following your progress, Xeres, I am very interrested with this feature and I think it will make a great addition to MODx feature... too bad I can’t help you yet (early stage of php learning here...).
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 32847
        • 171 Posts
        Thanks David,

        don’t hope a great piece a code and there is certainly a better way to do that.

        As I said, this works only with published doc.
        Create a plugin and chek OnDocFormSave in the system event
        //get info from db
        $tblContent= $modx->getFullTableName('site_content');
        $query= "SELECT parent, pagetitle , createdon, editedon FROM $tblContent WHERE id = '$id'";
        $doc= $modx->dbQuery($query);
        $doc= $modx->db->getRow($doc);		
        
        $create = $doc['createdon'];
        $edit = $doc['editedon'];
        $parent= $doc['parent'];
        $title = $doc['pagetitle'];
        
        //send mail 
        
        if ($create == $edit && $parent == ??) /replace ?? by your folder or remove
        {
        $e = &$modx->Event;
        switch($e->name) {
          case 'OnDocFormSave':
            mail("mail@mydomain", "New article: $title", "new article waiting for validation");
            break;
          default:
            break;
         }
        }

          • 32241
          • 1,495 Posts
          I come to the rescue xeres wink But, as usual, I will only give a few tips and suggestions laugh

          Check out the original API
          function getDocument($id=0,$fields="*",$published=1, $deleted=0)
          


          If you set $published to 0, you will get the unpublished document. Currently, our MODx API is not flexible enough to let developer fetch both publish & unpublished doc at the same time. If you want to aachieve that, a good example will be newslisting, which is not a good way to do it, by accessing database directly, but if there is no way to do it with the current API, then that’s the only way, like what Mark did.
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 32847
            • 171 Posts
            I understand now!
            I already thought accessing database directly and I am going to look Mark snippet
            Thanks Wendy
              • 6726
              • 7,075 Posts
              Hmmm, I have lots of new input about this kind of feature from a potential client.

              He wants :


              • to have the ability to define wether or not a document should be included in notification of new content (probably use a checkbox TV here)
              • to enable users to sign up for the updates and manage their subscription (for instance, choose frequency of notification)
              • be able to have different templates for different sections of the website (e.g it would mean having a startdoc parameter or something for each news batch, and a chunk to format the email notifications itself)
              • to have a basic personnalisation for each user (like, having their name displayed)

              Writing this, I realize I am talking about notification of new content and should rather look to the NewsLetter snippet and see if it can do all those things...

              Not saying I wouldn’t like the ability to have other type of "events" notified by email there, could even be a real plus for MODx now that I think about it....
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l'outil id
                • 18397
                • 3,250 Posts
                Quote from: davidm at Feb 28, 2006, 10:54 AM


                • to have the ability to define wether or not a document should be included in notification of new content (probably use a checkbox TV here)
                • to have a basic personnalisation for each user (like, having their name displayed)

                I actually wrote that for my NewsLetter Module/Snippet/Plugin bit. I can extract the code that does that and post if people wish.
                  • 6726
                  • 7,075 Posts
                  Quote from: Mark at Feb 28, 2006, 01:11 PM
                  I actually wrote that for my NewsLetter Module/Snippet/Plugin bit. I can extract the code that does that and post if people wish.

                  You mean you are working on another "branch" of the snippet Wendy’s working on ?

                  About the code for this : it would be great Mark !
                  If I get this contract I’ll sponsor the development of this Module/Snippet/plugin bit you’re talking about... smiley
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 32847
                    • 171 Posts
                    I updated my code above and it is fully usefull for both published and unpublished.
                    Thanks to Wendy for tips

                    Hope it helps
                      • 6726
                      • 7,075 Posts
                      Quote from: Mark at Feb 28, 2006, 01:11 PM
                      I actually wrote that for my NewsLetter Module/Snippet/Plugin bit. I can extract the code that does that and post if people wish.

                      Any chance you could post it ?

                      I think in the long run, this could become a much expected feature for MODx to have notification for all kinds of event : new user, new document, document modification, new file uploaded... etc.

                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l'outil id