We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23082
    • 8 Posts
    Peter Friswell Reply #1, 18 years ago
    Is there a way to produce a simple report that lists all the unpublished documents?

    Cheers

    Peter
      I
      • 4310
      • 2,310 Posts
      Here’s a snippet that will produce a list of id’s and pagetitles that are unpublished.

      <?php
      $output = '';
      $output .='<ul>';
      $sql = mysql_query('SELECT * FROM `modx_site_content` WHERE `published`= 0 ORDER BY `id` ASC ');
      $resultArray = $modx->db->makeArray( $sql );
      foreach($resultArray as $item)
      {
      $output .= '<li>'.$item['id'].' - '.$item['pagetitle'].'</li>';
      }
      $output .='</ul>';
      return $output;
      ?>
        • 23082
        • 8 Posts
        Peter Friswell Reply #3, 18 years ago
        Thanks for the snippet.

        When I ran it I got this error

        Parse error: syntax error, unexpected ’[’ in /www/derma/manager/processors/execute_module.processor.php(98) : eval()’d code on line 1

        Did I do something wrong?

        Peter
          I
          • 4310
          • 2,310 Posts
          Have you put the code into a new snippet, named it, saved it & then called the snippet on a page as [[NameofSnippett]] ?
          It works for me!
            • 23082
            • 8 Posts
            Peter Friswell Reply #5, 18 years ago
            No. I have never done that before. I have only ever created new modules which is what I did in this case. embarrassed

            Any chance you can give me an idiots guide?

            Cheers

            Peter

              I
              • 16183
              • 1,390 Posts
              Quote from: Peter at Sep 10, 2008, 04:58 AM

              No. I have never done that before. I have only ever created new modules which is what I did in this case. embarrassed

              Any chance you can give me an idiots guide?

              Cheers

              Peter

              Copied from modx documentation here: http://modxcms.com/adding-snippets.html

              To install a new snippet, log in to the Manager and go to Manage resources and open the Snippets tab. Click on the New snippet link to open the form. Copy/paste the code from your snippet’s source, usually a text file that you open in a text editor, into the textarea, give it a name and a brief description. You can name a snippet anything you like, just remember that the name you give it is how you will need to call it later in your template or document source.

              Then call it in your documents/templates like bunker58 has mentioned above: [[NameofSnippett]]  or [!NameofSnippett!] in case you want it uncached

              /k
                • 29076
                • 615 Posts
                  I think, thererfor I am! But what I am, and why...?
                  • 16183
                  • 1,390 Posts
                  Quote from: Sylvaticus at Sep 10, 2008, 06:02 AM


                  (kongondo, you got me with a second there laugh )

                  grin wink
                    • 23082
                    • 8 Posts
                    Peter Friswell Reply #9, 18 years ago
                    Thanks for your help.

                    Peter
                      I
                      • 3749
                      • 24,544 Posts
                      @bunk58,

                      Nice one.

                      You could add parameters &listPublished, &listUnPublished, format the output a little and this baby would be a great addition to the Repository (PublicationReport Snippet?).

                      Version 2.0 can have a tpl and the option of having the lists mixed or separate. wink

                        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