We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19975
    • 429 Posts
    I am looking to use a PHPJabber Vacation Rental script http://www.phpjabbers.com/vacation-rental-script/ to manage a portfolio of properties and then use MODx templates to present the data.

    Are there any detailed docs on how this can be achieved? Any pointers warmly welcomed. [ed. note: SandersDesign last edited this post 12 years, 3 months ago.]
      Martin Sanders - Design & Web Development
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It would probably be best to make xPDO objects out of the script's database tables, then you can use the MODX API to work with them.

      http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/using-custom-database-tables-in-your-3rd-party-components
        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
        • 19975
        • 429 Posts
        Hi Sottwell, thanks for the link.

        I have been following the "Custom Database Tables" from Bob's Guides at http://bobsguides.com/custom-db-tables.html and have been able to partially run the "Create XPDO Classes" (some tables indicated missing ID primary key even tho row included ID fields) script but I'm currently having trouble getting the code from "Show Quotes" snippet to work with my application tables.

        I have attached the MySQL database and files produced vis the "Create XPDO Classes" snippet.

        If anyone can provide advise I would be extremely grateful.

        $path = MODX_CORE_PATH . 'components/bookingsystem/';
        $result = $modx->addPackage('bookingsystem',$path .
            'model/bookingsystem/','booking_');
         
        if (! $result) {
            return 'failed to add package';
        } else {
            $output = '<p>added Package</p>';
        }
         
        $quotes = $modx->getCollection('vacationrentalslistings');
          
        foreach($quotes as $quote) {
            $output .= '<p>owner_id: ' . $quote->get('owner_id');
        }
         
        return $output;
          Martin Sanders - Design & Web Development
          • 3749
          • 24,544 Posts
          In your schema, the class is "VacationrentalsListings", not "vacationrentalslistings". That could be causing trouble.

          BTW, by convention, xPDO objects usually (but not always) begin with a lowercase letter and are singular (since the object itself contains info on only one listing). Related object Aliases begin with a capital letter. In this case calling the class 'vacationRentalListing' would make sense, though you're absolutely free to use whatever terms you like.

          For example:

          class: modResource
          alias: Parent
          alias: Children

            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
            • 19975
            • 429 Posts
            Thanks for your help bob. As the script uses many interconnecting tables I decided to use the default script pages but convert the templates to render as xml rss. I have then imported data via xpath into modx using a snippet.
              Martin Sanders - Design & Web Development