We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26388
    • 103 Posts
    Ok I feel like I’m getting somewhere but keep running into issues. Now, I have all the files in place and when I test the snippet I get this displayed:
    modx =& $modx; $basePath = $this->modx->getOption(’getvendors.core_path’,$config,$this->modx->getOption(’core_path’).’components/getvendors/’); $assetsUrl = $this->modx->getOption(’getvendors.assets_url’,$config,$this->modx->getOption(’assets_url’).’components/getvendors/’); $this->config = array_merge(array( ’basePath’ => $basePath, ’corePath’ => $basePath, ’modelPath’ => $basePath.’model/’, ’processorsPath’ => $basePath.’processors/’, ’chunksPath’ => $basePath.’elements/chunks/’, ’jsUrl’ => $assetsUrl.’js/’, ’cssUrl’ => $assetsUrl.’css/’, ’assetsUrl’ => $assetsUrl, ’connectorUrl’ => $assetsUrl.’connector.php’, ),$config); $this->modx->addPackage(’getvendors’,$this->config[’modelPath’],’swc_’); } }

    Check the server’s log file and discover it can’t find my class GetVendors:
    [Thu Feb 03 21:53:30 2011] [error] [client 24.9.59.181] PHP Fatal error: Class ’GetVendors’ not found in /var/www/vhosts/tourwyoming.com/httpdocs/core/xpdo/xpdo.class.php on line 955, referer: http://tourwyoming.signature-ad.com/

    My snippet and base class files are attached for reference..

    Snippet file:
    <?php
    
    $getvendors = $modx->getService('getvendors','GetVendors',$modx->getOption('getvendors.core_path',null,$modx->getOption('core_path').'components/getvendors/').'model/getvendors/',$scriptProperties);
    if (!($getvendors instanceof GetVendors)) return '';
    
    
    /* setup default properties */
    $table = $modx->getOption('select',$scriptProperties);
    $tpl = $modx->getOption('tpl',$scriptProperties,'rowTpl');
    $sort = $modx->getOption('sort',$scriptProperties,'name');
    $dir = $modx->getOption('dir',$scriptProperties,'ASC');
    
    
    $vendors = $modx->getCollection('Attraction');
    $output = count($vendors);
    
    return $output;


    Base class file:
    <?php
    
    class GetVendors {
    	public $modx;
    	public $config = array();
    	function __construct(modX &$modx,array $config = array()) {
    		$this->modx =& $modx;
    
    		$basePath = $this->modx->getOption('getvendors.core_path',$config,$this->modx->getOption('core_path').'components/getvendors/');
    		$assetsUrl = $this->modx->getOption('getvendors.assets_url',$config,$this->modx->getOption('assets_url').'components/getvendors/');
    		$this->config = array_merge(array(
    			'basePath' => $basePath,
    			'corePath' => $basePath,
    			'modelPath' => $basePath.'model/',
    			'processorsPath' => $basePath.'processors/',
    			'chunksPath' => $basePath.'elements/chunks/',
    			'jsUrl' => $assetsUrl.'js/',
    			'cssUrl' => $assetsUrl.'css/',
    			'assetsUrl' => $assetsUrl,
    			'connectorUrl' => $assetsUrl.'connector.php',
    		),$config);
    
    		$this->modx->addPackage('getvendors',$this->config['modelPath'],'swc_');
    	}
    }


      • 26388
      • 103 Posts
      Anyone have any thoughts to why it’s not finding my class ’GetVendors?’
        • 3749
        • 24,544 Posts
        Do you have a schema that specifies what table getVendors refers to, and did you generate the map file(a) using that schema?
          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
          • 26388
          • 103 Posts
          Quote from: BobRay at Feb 09, 2011, 05:19 PM

          Do you have a schema that specifies what table getVendors refers to, and did you generate the map file(a) using that schema?

          Yes my schema specifies multiple tables but there is no table called ’GetVendors.’ I’ve run the build.schema.php script and it produced all my class and map files for my tables. I’ve attached my entire component directory in case that helps anyone discern what I’m missing..
            • 3749
            • 24,544 Posts
            It doesn’t have to be called GetVendors, but the table referred to in the schema for that object has to exist (and I think the names are case-sensitive).

            Could you paste your schema here? I’m not seeing it in the .zip file.
              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
              • 26388
              • 103 Posts
              Quote from: BobRay at Feb 09, 2011, 05:55 PM

              It doesn’t have to be called GetVendors, but the table referred to in the schema for that object has to exist (and I think the names are case-sensitive).

              Could you paste your schema here? I’m not seeing it in the .zip file.

              Surely (there are many more objects (tables) in my full schema):
              <?xml version="1.0" encoding="UTF-8"?>
              <model package="getvendors" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
              	<object class="Amenity" table="amenity" extends="xPDOObject">
              		<field key="amenityID" dbtype="int" precision="11" phptype="integer" null="false" default="" index="pk" />
              		<field key="name" dbtype="varchar" precision="100" phptype="string" null="true" />
              		<field key="iconImage" dbtype="varchar" precision="100" phptype="string" null="true" />
              		<field key="feedName" dbtype="varchar" precision="50" phptype="string" null="true" />
              		<field key="forRestaurant" dbtype="tinyint" precision="4" phptype="integer" null="true" />
              		<field key="forLodging" dbtype="tinyint" precision="4" phptype="integer" null="true" />
              		<field key="forAttraction" dbtype="tinyint" precision="4" phptype="integer" null="true" />
              		<field key="isActive" dbtype="tinyint" precision="4" phptype="integer" null="false" default="" />
              
              		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
              			<column key="amenityID" length="" collation="A" null="false" />
              		</index>
              	</object>
              	<object class="Attraction" table="attraction" extends="xPDOObject">
              		<field key="attractionID" dbtype="int" precision="11" phptype="integer" null="false" default="" index="pk" />
              		<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              		<field key="address1" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              		<field key="address2" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              		<field key="city" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
              		<field key="state" dbtype="char" precision="2" phptype="string" null="false" default="" />
              		<field key="zip" dbtype="varchar" precision="10" phptype="string" null="false" default="" />
              		<field key="website" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              		<field key="pdf1" dbtype="varchar" precision="255" phptype="string" null="true" />
              		<field key="pdf2" dbtype="varchar" precision="255" phptype="string" null="true" />
              		<field key="pdf3" dbtype="varchar" precision="255" phptype="string" null="true" />
              		<field key="picture" dbtype="varchar" precision="255" phptype="string" null="true" />
              		<field key="email" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              		<field key="phoneArea" dbtype="varchar" precision="3" phptype="string" null="true" />
              		<field key="phonePrefix" dbtype="varchar" precision="3" phptype="string" null="true" />
              		<field key="phoneSuffix" dbtype="varchar" precision="4" phptype="string" null="true" />
              		<field key="phone" dbtype="varchar" precision="50" phptype="string" null="false" default="" />
              		<field key="faxArea" dbtype="varchar" precision="3" phptype="string" null="true" />
              		<field key="faxPrefix" dbtype="varchar" precision="3" phptype="string" null="true" />
              		<field key="faxSuffix" dbtype="varchar" precision="4" phptype="string" null="true" />
              		<field key="fax" dbtype="varchar" precision="50" phptype="string" null="false" default="" />
              		<field key="description" dbtype="longtext" phptype="string" null="false" default="" />
              		<field key="latitude" dbtype="double" phptype="float" null="false" default="" />
              		<field key="longitude" dbtype="double" phptype="float" null="false" default="" />
              		<field key="isVignette" dbtype="tinyint" precision="4" phptype="integer" null="false" default="" />
              		<field key="googleCID" dbtype="varchar" precision="50" phptype="string" null="true" />
              		<field key="dateCreated" dbtype="datetime" phptype="datetime" null="false" default="" />
              		<field key="lastUpdated" dbtype="datetime" phptype="datetime" null="false" default="" />
              
              		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
              			<column key="attractionID" length="" collation="A" null="false" />
              		</index>
              	</object>
              </model>

                • 3749
                • 24,544 Posts
                I don’t see anything obvious (though Shaun might). I would try something like this first to make sure the path is getting set correctly:

                $path = $modx->getOption('getvendors.core_path',null,$modx->getOption('core_path').'components/getvendors/').'model/getvendors/';
                $getvendors = $modx->getService('getvendors','GetVendors',$path,$scriptProperties);
                if (!($getvendors instanceof GetVendors)) return 'Error - Path: ' . $path;
                  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
                  • 26388
                  • 103 Posts
                  Quote from: BobRay at Feb 09, 2011, 09:13 PM

                  I don’t see anything obvious (though Shaun might). I would try something like this first to make sure the path is getting set correctly:

                  $path = $modx->getOption('getvendors.core_path',null,$modx->getOption('core_path').'components/getvendors/').'model/getvendors/';
                  $getvendors = $modx->getService('getvendors','GetVendors',$path,$scriptProperties);
                  if (!($getvendors instanceof GetVendors)) return 'Error - Path: ' . $path;


                  Thanks Bob. Well, I tried this and it produced the same result... I think I’m going to start from scratch again and walk through the developing an extra doc.
                    • 3749
                    • 24,544 Posts
                    You might try this as an alternative: http://bobsguides.com/custom-db-tables.html. It assumes that you already have the tables. I would try it with just one table to begin with.
                      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