We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25226
    • 29 Posts
    I had login controls in the page Template but I just removed it and it still doesnt work.

      • 11055 ☆ A M B ☆
      • 3,112 Posts
      after clear cache?
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 25226
        • 29 Posts
        Yes, cleared site cache. also checked login code and it doesnt have a an id,name, or value of ’submit’
          • 11055 ☆ A M B ☆
          • 3,112 Posts
          If it’s live, do you mind to get me into the manager?
          PM me access if you don’t.
            Rico
            Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
            MODx is great, but knowing how to use it well makes it perfect!

            www.virtudraft.com

            Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

            Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

            Maintainter/contributor of Babel

            Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
            • 11055 ☆ A M B ☆
            • 3,112 Posts
            lol...
            the problem was easy:
            <?php // highlighting
            // $result = $modx->addPackage('quotes', $path . 'model/', 'bobs_');
            $modx->addPackage('quotes', $path . 'model/', 'bobs_');
            


            I also changed the output a little bit, only to create a ’back’ hyperlink.

            And use the snippet uncached [[!EditQuote]]
              Rico
              Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
              MODx is great, but knowing how to use it well makes it perfect!

              www.virtudraft.com

              Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

              Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

              Maintainter/contributor of Babel

              Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
              • 25226
              • 29 Posts
              OMG!!! This whole time I didnt even see it.

              Thank you!

              For any noobs that have been following this, I will post complete solution soon.

                • 3749
                • 24,544 Posts
                That’s one error that code editors will almost never catch, because it’s still valid PHP.

                I’ve added it to the Insidious MODx Errors page: http://bobsguides.com/insidious-modx-errors.html

                  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
                  • 25226
                  • 29 Posts
                  Ok, for anyone that was following this thread or wants to know how to create a custom table and form to create records, return records, and edit records here is the code for it on the most basic level. It was started by BobRays tutorial on Custom Tables you can find here and debugged with the help of this forums members like BobRay and goldsky. Thank you.

                  First you need to go to BobRays tutorial http://bobsguides.com/custom-db-tables.html to setup xPDO schemas and classes

                  then use this code(note: pay attention where the resources, snippets, and chunks start and end as they belong in separate files).

                  
                  
                  //Modifications need to be done to the "ShowQuotes" snippet from the tutorial
                  <?php
                  //begin snippet
                  $path = MODX_CORE_PATH . 'components/quotes/';
                  $result = $modx->addPackage('quotes', $path . 'model/', 'bobs_');
                  
                  
                  $quotes = $modx->getCollection('Quotation');
                  
                  $output .= '<p>Total: ' . count($quotes) . '</p>';
                  
                  foreach ($quotes as $quote) {
                  
                  $output .= $modx->getChunk('quoteTpl', $quote->toArray());
                  
                  }
                  
                  return $output;
                  
                  // end snippet
                  // ?>
                  //The "ShowQuotes" resource
                  <html>
                  //begin resource
                  [[ShowQuotes]]
                   
                  
                  //end resource
                  </html>
                  //The "quoteTpl" chunk references above
                  <html>
                  //begin chunk
                  
                  Author: [[+author]]<br />
                  Quote: [[+quote]]<br />
                  Topic: [[+topic]]<br />
                  <a href="[[~41? &scheme=`full` &quoteId=`[[+id]]` ]]">Edit</a><br />
                  
                  //end chunk
                  </html>
                  //The "FormEdit" resource(has resource id of 41)
                  <html>
                  //begin resource
                  
                  [[!EditQuote]]
                  
                  //end resource
                  </html>
                  //The "EditQuote" snippet
                  
                  <?php
                  //begin snippet
                  
                  $scriptProperties['quoteId'] = !empty($_GET['quoteId']) ? intval($_GET['quoteId']) : '';
                  if (empty($scriptProperties['quoteId'])) {
                      // or you want to echo out any text
                      return '';
                  }
                  
                  /* Get the existing Quote */
                  
                  $path = MODX_CORE_PATH . 'components/quotes/';
                  $modx->addPackage('quotes', $path . 'model/', 'bobs_');
                  $quote = $modx->getObject('Quotation', array('id' => $scriptProperties['quoteId']));
                  
                  if (isset($_POST['submit']) && $_POST['submit'] == 'submit') {
                  
                      /**
                       * Try to see whether the field's values are empty or not, using:
                       * die(print_r($_POST));
                       */
                      /* Form has been submitted */
                      // @todo sanitize the input values, this is IMPORTANT!
                  
                      $quote->set('topic', $_POST['topic']);
                      $quote->set('quote', $_POST['quote']);
                      $quote->set('author', $_POST['author']);
                  
                      if ($quote->save()) {
                          $output = "<p>Quote Created</p>";
                          $output .= '<a href="[[~22? &scheme=`full`]]">back</a>';
                      } else {
                          $output = "<p>Error when trying to save</p>";
                          $output .= '<a href="[[~22? &scheme=`full`]]">back</a>';
                      }
                  } else {
                  
                      /* Not a repost, just display the form */
                  
                      /* The second argument to getChunk() tells MODx to replace
                       * the placeholders with the existing quote's values
                       */
                      $output = $modx->getChunk('quotationTplEdit', $quote->toArray());
                  }
                  return $output;
                  
                  //end snippet
                  ?>
                  //Now is to create a brand new record
                  // The "CreateQuote" snippet
                  <?php
                  //begin snippet
                  
                  if (isset($_POST['submit']) && ($_POST['submit'] == 'submit')) {
                      /* Form has been submitted */
                      /* You might want to check for empty required fields here */
                      $path = MODX_CORE_PATH . 'components/quotes/';
                      $result = $modx->addPackage('quotes', $path . 'model/', 'bobs_');
                      $fields = array(
                          'topic' => $_POST['topic'],
                          'quote' => $_POST['quote'],
                          'author' => $_POST['author'],
                      );
                      $quote = $modx->newObject('Quotation', $fields);
                      if ($quote->save()) {
                          $output = "Quote Created";
                      } else {
                          $output = "Error";
                      }
                  } else {
                      /* Not a repost, just display the form */
                      $output = $modx->getChunk('quotationTpl');
                  }
                  return $output;
                  
                  //end snippet
                  ?>
                  //The "quotationTpl" chunk
                  <html>
                  //begin chunk
                  
                  
                  <form method="post" action="[[~[[*id]]]]">
                                  <input type="hidden" name="quoteId" value="[[+id]]" />
                                  <input type="text" name='topic' id='topic' value="[[+topic]]" />
                                  <input type="text" name='quote' id='quote' value="[[+quote]]" />
                                  <input type="text" name='author' id='author' value="[[+author]]" />
                                  <input type='submit' name='submit' id='submit' value='submit'/>
                  
                  </form>
                  
                  //end chunk
                  </html>
                  //The "Form" resource
                  <html>
                  //begin resource
                  
                  [[!CreateQuote]]
                  
                  //end resource
                  </html>
                    • 11055 ☆ A M B ☆
                    • 3,112 Posts
                    I think it’s better you split the snippet’s and chunk’s BBC codes one by one.
                    Makes it easier to read.

                    Anyway, // The "CreateQuote" snippet
                    <?php // highlighting
                    // $result = $modx->addPackage('quotes', $path . 'model/', 'bobs_');
                    $modx->addPackage('quotes', $path . 'model/', 'bobs_');
                    
                      Rico
                      Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                      MODx is great, but knowing how to use it well makes it perfect!

                      www.virtudraft.com

                      Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                      Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                      Maintainter/contributor of Babel

                      Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.