We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39990
    • 45 Posts
    I have been working on the Doodles tutorial the past few days and I keep getting stuck with creating the doodles tables in my database. I have Revolution 2.2.2-pl instillation.

    Everything in this tutorial has run smoothly until I get to creating the tables. The model and parsing script work perfectly, creating the necessary maps and classes, but when I run snippet.doodles.php with the code that should create the doodles table placed before the return statement, nothing happens. I don't get a return statement saying whether it worked or not, no new tables, or even an error. Just a blank page. Has anyone run into this problem before? Does this have something to do with incorrect permissions to files?
      • 1441
      • 61 Posts
      I've had this happen too. Are you sure the snippet being processed?

      (BTW: In my case - after checking php log files - I found my path variables to be improperly defined)
        • 39990
        • 45 Posts
        Thank you for your quick response!

        I believe it is. What is the best way to make sure it is being processed? If my path variables were improperly defined, do you think that the build steps would still work?

        What log files did you check? Apache or modx log files? [ed. note: jsteffan1 last edited this post 13 years, 10 months ago.]
          • 33968
          • 863 Posts
          Quote from: jsteffan1 at Nov 19, 2012, 02:52 PM
          What is the best way to make sure it is being processed?
          Have it return something to indicate success or failure.

          Want to post your snippet here?
            • 39990
            • 45 Posts
            If I return anything after the dood variable and if statment nothing returns. I have also tried echo's but it is the same thing... Here is my snippet.doodles.php code:

            <?php
            /**
             * @package doodles
             */
            
            $dood = $modx->getService('doodles','Doodles',$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/doodles/').'model/doodles/',$scriptProperties);
            if (!($dood instanceof Doodles)) return '';
            
            /* setup default properties */
            $tpl = $modx->getOption('tpl',$scriptProperties,'rowTpl');
            $sort = $modx->getOption('sort',$scriptProperties,'name');
            $dir = $modx->getOption('dir',$scriptProperties,'ASC');
            
            $m = $modx->getManager();
            $created = $m->createObjectContainer('Doodle');
            return $created ? 'Table created.' : 'Table not created.';
            
            return $output;
            
            


            I have set the doodles.core_path and doodles.assets_url inside of my system settings. They are working because the path for the static snippet ([[++doodles.core_path]]/elements/snippets/snippet.doodles.php) is pulling the correct file.


            My modx error log has this in it:
            [2012-11-20 17:46:13] (ERROR @ /modx/index.php) Could not load class: Doodles from doodles.
            [2012-11-20 17:46:13] (ERROR @ /modx/index.php) Problem getting service doodles, instance of class Doodles, from path /srv/www/htdocs/modx/doodles/core/components/doodles/model/doodles/

            I have checked the path and it exists and is correct. All of my classes and maps are located inside of the 3rd doodles folder in the path including my doodles.class.php file that looks like this:

            	class Doodles {
                public $modx;
                public $config = array();
                function __construct(modX &$modx,array $config = array()) {
                    $this->modx =& $modx;
             
                    $basePath = $this->modx->getOption('doodles.core_path',$config,$this->modx->getOption('core_path').'components/doodles/');
                    $assetsUrl = $this->modx->getOption('doodles.assets_url',$config,$this->modx->getOption('assets_url').'components/doodles/');
                    $this->config = array_merge(array(
                        'basePath' => $basePath,
                        'corePath' => $basePath,
                        'modelPath' => $basePath.'model/',
                        'processorsPath' => $basePath.'processors/',
                        'templatesPath' => $basePath.'templates/',
                        'chunksPath' => $basePath.'elements/chunks/',
                        'jsUrl' => $assetsUrl.'js/',
                        'cssUrl' => $assetsUrl.'css/',
                        'assetsUrl' => $assetsUrl,
                        'connectorUrl' => $assetsUrl.'connector.php',
                    ),$config);
            		
            		$this->modx->addPackage('doodle',$this->config['modelPath']);
             
                }
            }


            Does it need the <?php at the top? It didn't have it on the tutorial... [ed. note: jsteffan1 last edited this post 13 years, 10 months ago.]
              • 33968
              • 863 Posts
              Quote from: jsteffan1 at Nov 20, 2012, 09:54 AM

              Does it need the <!--?php at the top? It didn't have it on the tutorial...-->
              Yep. Same goes for any static php files you create.

              Line 22 of your Doodles Class should contain an 's' after 'doodle':
              $this->modx->addPackage('doodles',$this->config['modelPath']);
              

              (this should match the first parameter given to getService() in your snippet)
              $modx->getService('doodles','Doodles'.....
              


              Also, does your setting for doodles.core_path end in a trailing slash '/'? It should.
                • 39990
                • 45 Posts
                Thank you so much for your help Lucas! I have updated my Doodles class by adding the 's' to the end of 'doodle' as well as checked to make sure that my doodles.core_path does have a '/' at the end. When I run it I still get the same error as before and a blank page.

                I have custom tables in this modx instillation, that I would like the ability to managed with CMP's. That is the reason I am trying to work through the doodles tutorial. I have created a model of my custom tables and verified that it works properly. Do you know of another tutorial that would teach me how to create the UI and interaction with these tables as a CMP (ExtJS)?

                Thank You again for your help!!
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I think you might be better off using MIGXdb as a back-end CMP. There is a good tutorial on using it to create the back-end for Doodles instead of having to build it up from scratch. http://rtfm.modx.com/display/ADDON/MIGXdb
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 39990
                    • 45 Posts
                    Thank you! I am defiantly going to look into this!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      It took me several tries before I finally got the Doodles tutorial to work; I spent a little time editing the tutorial, but there are still a lot of little oddities and gotchas in it. I did think I had taken care of all the code without opening php tags, though.
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org