Hello,
We have a website in maintenance which is build in a self-build CMS based
on ZendFramework and something ridiculously complicated with Ajax...
My customer wants some extra functionality in that CMS system.
My idea is to install MODX next to that system, let the users do the
maintenance of that part of the website in MODX (not the pages, but probably
they will be Chunks), and modify the ZendFramework code to read straight
from the MODX tables.
My question is if it is possible to read chunks or documents from
another system than MODX. Some sort of API on MODX as a whole.
Thanks in advance for your time and aswers,
Bert Catsburg
-
☆ A M B ☆
- 24,524 Posts
If you just want to get the content of the chunk or resource, you can easily access the site_htmlsnippets table or the site_content table. If you want dynamic content (content after a snippet has been run, for example) you could have the snippet on a resource with no template, and use the actual resource’s URL to have MODx process it.
The Vanilla forum’s single sign-on plugin does this; it uses a MODx (or any other external application) page with a snippet to generate the user data from the MODx login and scrapes that data to have the user logged in to the Vanilla system.
Hm, you’re right in your second example. I could just run the url in an iframe. But I think it might be too mucht overhead. I need different ’blocks’ in that site, so every block would start up the whole MODX-system.
The first example also crossed my mind. But I was hoping for some elegant solution in which you call MODX as an API. Link ’execute the config, load the MODX-class and go through the API to the MODX elements’.
Yes, you can do this, in your external script basically include the index.php file from MODx, you can cut this down a bit and set the in API MODE constant, this will create a modx object for you on which you can call the MODx API from your external scripts. remove the request handler at the bottom and your good to go.
Use MODx, or the cat gets it!
-
☆ A M B ☆
- 24,524 Posts
You can use cURL to open the URL and get the content from the page as a string. No iframe necessary.
http://www.php.net/manual/en/curl.examples-basic.php
Or if your PHP configuration allows opening URLs as files, you can use file_get_contents.
http://il2.php.net/manual/en/function.file-get-contents.php
Ok, that is clear. I have to test these solutions. Probably I will come back asking how far I can strip the index.php. But for the moment I take the full index.php.
Thanks, for all your help.
I believe this is all you need:
<?php
define('MODX_CORE_PATH', 'full/path/to/your/modx/core/');
define('MODX_CONFIG_KEY', 'config');
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
I think the xPDO class will come along for the ride.
You’ll need a correct core/config/config.inc.php file (if MODx is installed, it should already be there).
Hello BobRay,
Interesting solution.
Is this Evolution or Revolution?
Thanks Bobray for this usefull contribution. It was exactly what I was looking for to validate a form with an ajax request (server site validation and email)
Works perfectly!
Thanks for you site too, which is a gold mine...
Equilibre Webdesign - Conception et r