We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15051
    • 7 Posts
    Quote from: Bruno17 at Sep 20, 2010, 11:23 AM

    after running this code...

    That’s great but....run it how? Paste it as a snippet and then put the snippet on a resource page? Seems a bit of a hack. Run it from the command line? Will need to include modx in that case. What’s the recommended and/or fastest way to do this? Could there be a utility CMP made for this kind of thing? (Excuse my ignorance I’m on day 3 of using MODx)

    Also, it seems to me, this would be a common enough use case that there might be justification for adding a convenience method to Generator e.g.

    $generator->writeAndParseSchema($packageName, $prefix, $restrictPrefix);
    



    The path(s) can default to e.g.:

    $modx->getOption('core_path') . 'components/'.$packageName.'/model
    


    The writeAndParseSchema convenience method can also create the necessary folders if they don’t already exist. Of course this is MODx specific so it perhaps shouldn’t go on the Generator class as that I presume is part of xPDO. So, instead, could this convenience wrapper be put on MODx somewhere?

    [OT] In fact, could there be a developer-oriented CMP that creates the standard folder layout for new components and other common setup for custom component development? Just thinking aloud here.
      • 4172
      • 5,888 Posts
      you can put this as part in your snippet which works with your tables.
      Check for existance of schema-file for example.
      If not exists run that part first.

      Or create a CMP, which calls that code per submit-button.


      [Edit]
      creating simple CMPs can be as easy as creating snippets with that code: http://modxcms.com/forums/index.php/topic,54729.msg315441.html#msg315441
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 1169
        • 312 Posts
        For getting started there is the package modExtra:-
        http://rtfm.modx.com/display/ADDON/modExtra

        And there is also Doodles in the Packet Management downloads

        This is an example by splittingred.

        Any of the Addons can be used as examples of Revolution coding.

        Hope this helps you.

        As you can see there are plenty of knowledgeable people around when you get stuck.

        Regards
          DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
          • 15083
          • 697 Posts
          Thanks Bruno....
          Where do I run the code?

          If I want to write data to a custom table using XPDO I now have to:

          1. Create the table in phpmyadmin
          2. Write an xml Schema that explains the table above
          3. Write a build file (build.config.php wold be helpful if this was included in the tutorial plz)
          4. Run this build file?
          5. Start using my new object as per the end of the tutorial.

          1. $modx->db->insert()......no?
          :)
            • 28215
            • 4,149 Posts
            Quote from: jusmeig at Sep 22, 2010, 09:14 AM

            1. Create the table in phpmyadmin
            2. Write an xml Schema that explains the table above
            3. Write a build file (build.config.php wold be helpful if this was included in the tutorial plz)
            4. Run this build file?
            5. Start using my new object as per the end of the tutorial.

            1. $modx->db->insert()......no?
            :)

            The problem with just using $modx->db->insert, is that it’s not database driver agnostic - meaning when MODx expands to support other databases such as sqllite, postgresql, mssql, etc, your code wont work on those platforms.

            xPDO-based code, however, will work.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 4172
              • 5,888 Posts
              here is a example how you can do that with formit:
              schema and classes for your package are autocreated in prehook if not exists.

              http://modxcms.com/forums/index.php/topic,54753.msg315571.html#msg315571
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 15083
                • 697 Posts
                Quote from: splittingred at Sep 22, 2010, 10:37 AM


                The problem with just using $modx->db->insert, is that it’s not database driver agnostic - meaning when MODx expands to support other databases such as sqllite, postgresql, mssql, etc, your code wont work on those platforms.

                xPDO-based code, however, will work.

                I know why it’s being done....and I know it makes sense and leads to a more powerful framework.....but at the end of the day......people are lazy smiley

                My next project will be done in Revo, and I will bite the bullet and hack through your tutorial. I’m sure once I get into the swing of things it will speed up the process.
                Expect questions smiley
                Thanks for the reply.