We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24075
    • 83 Posts
    Now:
    I Created
    pp.mysql.schema.xml
    in this folder
    /modx_rev/core/components/pp/model/category/schema/pp.mysql.schema.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <model package="category" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
     
        <object class="Cat" table="category" extends="xPDOSimpleObject">
            <field key="id" dbtype="smallint" precision="4" phptype="integer" null="false" default="" />
            <field key="name" dbtype="varchar" precision="64" phptype="string" null="false" default="" />
    		<field key="name_alt" dbtype="varchar" precision="128" phptype="string" null="false" default="" />
    		<field key="parent_id" dbtype="smallint" precision="4" phptype="integer" null="false" default="" />
    		<field key="view" dbtype="smallint" precision="2" phptype="integer" null="false" default="" />
        </object>
         
    </model>  


    build.config.php
    in folder:
    /modx_rev/_build/build.config.php

    <?php
    define('MODX_BASE_PATH', '/home/www/puschpull.org/www/modx_rev/');
    define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/');
    define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/');
    define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/');
    define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/');
     
    define('MODX_BASE_URL','/modx_rev/');
    define('MODX_CORE_URL', MODX_BASE_URL . 'core/');
    define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/');
    define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/');
    define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/');


    build.schema.php
    in folder:
    /modx_rev/_build/build.schema.php

    <?php
    require_once dirname(__FILE__).'/build.config.php';
    include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
    $modx= new modX();
    $modx->initialize('mgr');
    $modx->loadClass('transport.modPackageBuilder','',false, true);
    echo '<pre>'; /* used for nice formatting of log messages */
    $modx->setLogLevel(modX::LOG_LEVEL_INFO);
    $modx->setLogTarget('ECHO');
     
    $root = dirname(dirname(__FILE__)).'/';
    $sources = array(
        'model' => $root.'core/components/pp/model/',
        'schema_file' => $root.'core/components/pp/model/schema/pp.mysql.schema.xml',
    );
    $manager= $modx->getManager();
    $generator= $manager->getGenerator();
     
    if (!is_dir($sources['model'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Model directory not found!'); die(); }
    if (!file_exists($sources['schema_file'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Schema file not found!'); die(); }
    $generator->parseSchema($sources['schema_file'],$sources['model']);
     
    echo 'Done.';
    exit();
    



    I run this adress
    puschpull.org/modx_rev/_build/build.schema.php

    and view "Done"

    schema is now
    /modx_rev/core/components/pp/model/category/mysql/
    /modx_rev/core/components/pp/model/category/mysql/cat.class.php
    /modx_rev/core/components/pp/model/category/mysql/cat.map.inc.php
    /modx_rev/core/components/pp/model/category/cat.class.php
    /modx_rev/core/components/pp/model/category/metadata.mysql.php
    and
    /modx_rev/core/components/pp/model/category/schema/pp.mysql.schema.xml


    and question:
    what now ?

    Thanks!
      Petr Püschel, Czech Republic
      <hr>
      http://puschpull.org
      <hr>
      • 1778
      • 659 Posts
      Hello
      Even if your english is very bad I encourage you to have a look at http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution
      It's a step by step how to buil a custom component Shaun (the author) has detailed each step with explanation on the why and the what, and you have a complete example to create a simple add-on with a custom DB, back-end interface (Custom Manager Page) and so on...
      A very good start to understand what you're doing ...
      Cheers
        • 24075
        • 83 Posts
        Quote from: anso at Feb 28, 2012, 04:06 AM
        Hello
        Even if your english is very bad I encourage you to have a look at http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution
        It's a step by step how to buil a custom component Shaun (the author) has detailed each step with explanation on the why and the what, and you have a complete example to create a simple add-on with a custom DB, back-end interface (Custom Manager Page) and so on...
        A very good start to understand what you're doing ...
        Cheers

        Aaach!

        This is not simple sample !
        40 pages with many code

        a need first absolute simple package for very simple table and very simple "Select" from thos table with xpdo package

        I copy/paste all Shaun McCormick code in web server but a have noawareness about what i doing
        !:-(

          Petr Püschel, Czech Republic
          <hr>
          http://puschpull.org
          <hr>
          • 11055 ☆ A M B ☆
          • 3,112 Posts
          try google translate for this page:
          http://modx-id.com/references/tutorial/custom-database-part-1-data-schema-snippet-dan-chunk.html

          it's written in Indonesian.
            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.
            • 24075
            • 83 Posts
            I training with Doodles
            http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution

            between
            The Schema Parsing Script
            and
            The include Snippet
            before
            Building the Query


            I can get over :
            ?php
            $dood = $modx->getService('doodles','Doodles',$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/doodles/').'model/doodles/',$scriptProperties);
            echo 'cesta: '.$modx->getOption('core_path').'<br><hr>';
            echo '$dood: '.$dood.'<br><hr>';
            echo 'CESTA: '.$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/doodles/').'<br><hr>';
            
            if (!($dood instanceof Doodles)) return 'instance FAILED';
            
            /* setup default properties */
            $tpl = $modx->getOption('tpl',$scriptProperties,'rowTpl');
            $sort = $modx->getOption('sort',$scriptProperties,'name');
            $dir = $modx->getOption('dir',$scriptProperties,'ASC');
             
            $output = '';
             
            echo 'instance OK';
            
            return $output;
            



            every time on my screen is:
            instance FAILED

            :(

            http://puschpull.org/modx_rev/doodles


            I get step by step from this guides (sample Doodles)
            Where is potencional error ?
            (outside my stupid brain)
              Petr Püschel, Czech Republic
              <hr>
              http://puschpull.org
              <hr>
              • 11055 ☆ A M B ☆
              • 3,112 Posts
              Have you added the 'doodles.core_path' into the System Settings?
                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.
                • 3749
                • 24,544 Posts
                If your table is simple and it already exists, you might have better luck with this method: http://bobsguides.com/custom-db-tables.html


                ---------------------------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                MODX info for everyone: http://bobsguides.com/modx.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
                  • 24075
                  • 83 Posts
                  Quote from: goldsky at Mar 01, 2012, 08:00 PM
                  Have you added the 'doodles.core_path' into the System Settings?

                  Yes, sure!
                  :)

                  here:
                  http://puschpull.org/root/modx_forum/1.png
                  and
                  http://puschpull.org/root/modx_forum/2.png [ed. note: puschpull last edited this post 14 years, 7 months ago.]
                    Petr Püschel, Czech Republic
                    <hr>
                    http://puschpull.org
                    <hr>
                    • 24075
                    • 83 Posts
                    BobRay: Thanks!
                    I know this Link.
                    I try this sample
                      Petr Püschel, Czech Republic
                      <hr>
                      http://puschpull.org
                      <hr>
                      • 24075
                      • 83 Posts
                      So continuation:

                      I create model with CreateXpdoClasses (Bob Guides)

                      and now

                      <?php
                      $path = MODX_CORE_PATH . 'components/pepish/';
                      $result = $modx->addPackage('pepish',$path . 'model/','pp_');
                      echo '$result: '.$result.'<br>';
                       
                      if($result){
                        $c = $modx->newQuery('pp_category');
                        $c->sortby('name','ASC');
                        $pokus = $modx->getCollection('pp_category',$c);
                      }
                       echo '$pokus: '.$pokus.'<br>';
                       
                      foreach ($pokus as $pok) {
                         echo $pok->get('name')."\n";
                      }
                      
                      


                      And this make no print on screen ??

                      Only this:
                      $result: 1
                      $pokus:



                      pepish is &myPackage
                      pp_category is db table
                      name is column in this table
                        Petr Püschel, Czech Republic
                        <hr>
                        http://puschpull.org
                        <hr>