We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27519
    • 275 Posts
    Did that. The good thing is that the calendar class appears to load properly now.

    However before I can create an instance of calendar, I need an instance of Cottage and modx.

    When I try to acces the cottage class, I get:

    [2011-02-03 15:13:29] (ERROR @ /index.php) Could not load class: Cottage from mysql.cottage.
    [2011-02-03 15:13:29] (ERROR @ /index.php) Cottage::load() is not a valid static method.
    

      MODx Revolution / MAMP / OS X
      • 28215
      • 4,149 Posts
      1. Add a trailing slash to your addPackage call path.
      2. Post your mysql xpdo schema file definition for the Cottage class.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 27519
        • 275 Posts
        I added the trailing slash but that did not make any difference.

        The map file is:

        <?php
        $xpdo_meta_map['Cottage']= array (
        	'package' => 'tariffs',
        	'table' => 'tariffs_cottages',
        	'fields' => array (
        		'name' => '',
        		'address' => '',
        		'postcode' => '',
        		'town' => '',
        		'sb_start' => '',
        		'sb_end' => '',
        		'tariff3' => '',
        		'tariff4' => '',
        		'tariff5' => '',
        		'tariff6' => '',
        		'allow_dogs' => '',
        		'max_dogs' => 0,
        		'max_sleeps' => 0,
        		'longtitude' => '',
        		'latitude' => '',
        		'confirmation_chunk_normal' => 0,
        		'confirmation_chunk_late' => 0
        	),
        	'fieldMeta' => array (
        		'name' => array (
        			'dbtype' => 'varchar',
        			'precision' => '255',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => '',
        		),
        		'address' => array (
        			'dbtype' => 'varchar',
        			'precision' => '255',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => '',
        		),
        		'postcode' => array (
        			'dbtype' => 'varchar',
        			'precision' => '8',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => 0,
        		),
        		'town' => array (
        			'dbtype' => 'varchar',
        			'precision' => '255',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => 0,
        		),
        		'sb_start' => array (
        			'dbtype' => 'char',
        			'precision' => '5',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => '',
        		),
        		'sb_end' => array (
        			'dbtype' => 'char',
        			'precision' => '5',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => '',
        		),
        		'tariff3' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'integer',
        			'null' => false,
        			'default' => 0,
        		),
        		'tariff4' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'integer',
        			'null' => false,
        			'default' => 0,
        		),
        		'tariff5' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'integer',
        			'null' => false,
        			'default' => 0,
        		),
        		'tariff6' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'integer',
        			'null' => false,
        			'default' => 0,
        		),
        		'max_dogs' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'int',
        			'null' => false,
        			'default' => 0,
        		),
        		'max_sleeps' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'int',
        			'null' => false,
        			'default' => 0,
        		),
        		'longtitude' => array (
        			'dbtype' => 'char',
        			'precision' => '10',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => 0,
        		),
        		'latitude' => array (
        			'dbtype' => 'char',
        			'precision' => '10',
        			'phptype' => 'string',
        			'null' => false,
        			'default' => 0,
        		),
        		'confirmation_chunk_normal' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'int',
        			'null' => false,
        			'default' => 0,
        		),
        		'confirmation_chunk_late' => array (
        			'dbtype' => 'int',
        			'precision' => '11',
        			'phptype' => 'int',
        			'null' => false,
        			'default' => 0,
        		),
        	),
        );
        

          MODx Revolution / MAMP / OS X
          • 27519
          • 275 Posts
          I don’t know whether it makes any difference but when I replace the addPackage for a loadClass for the Cottage class, the first error disappears (about not able to load class). However, the second remains (the one about the static method load()).

          It’s really weird because I’ve written a fair number of snippets without these problems popping up.
            MODx Revolution / MAMP / OS X
            • 27519
            • 275 Posts
            My last findings so far:

            - Dismembered the offending snippet to the level that it would only do a simple query on the Cottage class.
            - If the snippet is run as a custom hook in a Formit call, the above mentioned error messages appear in the MODx error log.
            - If the snippet is run as a normal snippet using the normal snippet tag, it runs the query without errors.

            My conclusion at the moment: there appears to be an issue with custom hooks in Formit that use DB operations...

            EDIT: As the cause remains unknown, I devised the following hack:

            - run the snippet on the "Thank you" page in stead of running it as a custom hook.
            - run the FormitRetriever before the snippet - this is important so you can retrieve your form values
            - in the snippet access the requested form values via $modx->getPlaceholder() as opposed to $hook->getValue()
              MODx Revolution / MAMP / OS X
              • 3749
              • 24,544 Posts
              Quote from: skndn60 at Feb 03, 2011, 06:32 PM

              I don’t know whether it makes any difference but when I replace the addPackage for a loadClass for the Cottage class, the first error disappears (about not able to load class). However, the second remains (the one about the static method load()).

              It’s really weird because I’ve written a fair number of snippets without these problems popping up.

              Are you checking the return value from addPackage()? It returns false on failure.
                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
                • 27519
                • 275 Posts
                Quote from: BobRay at Feb 04, 2011, 10:39 PM

                [Are you checking the return value from addPackage()? It returns false on failure.

                Yes. It returns true... huh
                  MODx Revolution / MAMP / OS X