We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    I would never try to match templates between the 2 or call APIs under the hood. At most I would put WordPress in its own directory, e.g. in /blog and let it handle the blog there. You may have to update your .htaccess file to let requests for dynamic pages pass through to WP’s own .htaccess file.
      • 18654
      • 191 Posts
      Why not run a script that accesses the WP API (which someone just recently posted in the extras) and then write the posts / comments either to an XML file or to custom database tables within ModX (or a cloud storage / DB service - although that would be an extra http request). Then, run a cron job once a day to update the XML files / custom DB tables / cloud storage. The cron job script could check for posts / comments that have been added or modified since the last time the script ran and then update only those.

      When users want to post comments, those comments would get posted directly to the WP database via the API, and then they would show up a day later after the cron job runs (assuming you run the cron job once a day).

      The nice thing about this approach (in theory, haven’t implemented it yet) is that you could easily aggregate data from multiple blogs. In my situation, I have 7 current chapters of an organization, each of which will have their own blog. I need to be able to aggregate this data and present in different ways (by chapter, by category, etc.)

      I’ve thought about alot of different approaches and this seems like the best way. I’d be open to ideas though if anyone else has input. The main advantages as I see it are as follows:

      1. Let’s say I have 50 chapters. I have to deal with user permissions for 50 users plus a single point of failure for 50 blogs (all the data stored on one DB server).
      2. The entire WP backend is geared towards managing posts, comments, etc and its very simple to use / setup.
      3. The users blog could double as their own site with whatever theme they want to use and whatever domain they want as well as integrating with ModX.
      4. The aggregated data could easily be accessed by multiple sites (Our organization has a number of interconnected sites that we’re working on)

      I’m currently doing something similar with Google Calendar. Using the Zend GData library I get all the upcoming events within a certain date range and bring them into ModX as resource objects. The script loops through all the public calendars in our organization’s account and then creates a container for each calendar with the events as children. The script also sets an unpublish date (along with a number of other TV’s) identifying when the event is over and automatically deletes the object once the event has ended.

      I’m actually just in the process of creating a context for each chapter and changing the script so that it places events under the appropriate context.

      The cron job runs once daily and updates existing events as well as creating any new events. I also made a "LockContent" variable in case users add additional info / formatting to the event in ModX - if the LockContent TV is set to "Yes" it won’t update the content field.

      Here’s the site (still very much a work in progres).
        God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
        • 22830
        • 4 Posts
        Quote from: rthrash at Apr 01, 2010, 11:35 PM

        What features do you need in a blog ... basic blogging/commenting/etc. or the other bits like trackbacks/pingbacks? If the former, what made you assume MODx was not up to par?

        There’s also widgets and the wp admin, but you’re right I should give the modx blog a try and see how it stands.
          • 18654
          • 191 Posts
          Quote from: paulmg at Apr 02, 2010, 01:49 PM

          There’s also widgets and the wp admin, but you’re right I should give the modx blog a try and see how it stands.
          I really like the WP widgets feature also - I had an idea about integrating that by using php curl and (as mentioned above) a cron job that runs daily. Simply create a page in WP that only outputs the contents of the side bar and then curl that page and use the html to create a chunk. If the the widget was sensitive to time (i.e a calendar that shows the current date) you would have to execute curl every time the page was loaded (which, unfortunately would require an extra http request but otherwise the calendar would show previous day as current day).

          Another option for integrating WP sidebar would be an iframe using the same approach but once again there we’re talking about an extra http request.

          EDIT

          This approach wouldn’t work for any widget that created internal links.

          Another thing I was thinking about was creating a resource in the ModX tree called "Sidebar" and then all resources placed under that container would be the equivalent of a widget. The particular widget could be determined by a template variable or the template itself. Definitely not as slick as the WP approach of simply drag-and-drop, but with a couple of extra steps could work the same.
          -matt
            God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
            • 5340
            • 1,624 Posts
            Quote from: oori at Apr 01, 2010, 07:09 PM

            As a simple workaround, you could always do it client-side ajax...
            $(’wpContainer’).load(’/wp/page.html’);


            +1. I never did it but that’s how I plan to do it if needed
              • 22295
              • 153 Posts
              QUOTE FROM: OORI ON 02-04-2010, 02:09:08
              As a simple workaround, you could always do it client-side ajax...
              $(’#wpContainer’).load(’/wp/page.html’);


              +1. I never did it but that’s how I plan to do it if needed

              And if you care for non-js clients (do they exist anymore?) you could add a old-school <noscript><iframe ...></script> to be sure they see your blog.

              also, if you care for SEO, you’d need to take care of that.
              one simple way would be:
              a. have <a href=’/wp/page.html’/> in the #wpContainer (which will be removed after the ajax load), but search engines will see.
              b. in the wp itself, add a redirector (backend or clientside) so in case somebody requests /wp/page.html directly, he’ll be redirected to you main page (which includes the wp inside...).


              note - this solution is really just a simple bypass which works, this is not integration..

              That said, I’d go with the others who say: just try using modx as a blog..