This is an auto-generated support/comment thread for
MODxAPI Library.
Use this forum to post any comments about this addition or any questions you have regarding its use.
Brief Description:
Use this api to connect to the MODx Content Managment System
Can this API be used in another MODx install under same domain/host? (or under multiple hosts also)
e.g. I have 2 MODx installs, one in root and other in subfolder, if I want to pull some content from subfolder into root then will this do it?
Thanks.
zi
Hi Zi,
Yes it should work just fine
The one thing that you would have to do is to use some other variable name for the MODxAPI instance:
$modx2 = new MODXAPI();
or maybe
$modxapi = new MODxAPI();
PS. The roadmap for MODxAPI 1.0 includes the ability to even use the API in languages other than PHP. Just imagine running a snippet from within a perl or ruby application!
Thanks Raymond!
What did you say? To use MODx API in other languages? if I am right then it will be a KILLER thing to come. wow.
Thanks man!
regards.
zi
I would like to start using the modx api in an external script but I don’t know what functions are available - The documentation online is (seems to be) incomplete. For example - the function the test script calls - executeDocument isn’t listed. I saw getChunk in Ditto and wanted for something I’m doing - but it didn’t work.
Is there a full API reference somewhere?
thanks,
Can I use this for developing my snippets and modules without having to load modules through the manager to test/debug?
-sD-
Quote from: yehosef at Oct 23, 2006, 05:44 AM
I would like to start using the modx api in an external script but I don’t know what functions are available - The documentation online is (seems to be) incomplete. For example - the function the test script calls - executeDocument isn’t listed. I saw getChunk in Ditto and wanted for something I’m doing - but it didn’t work.
Is there a full API reference somewhere?
thanks,
Hi yehosef,
MODxAPI is currently a simple extension to the MODx DocumentParser object. There’s not a lot of documentation for it just yet but here are some sample code showing how you can get started with chunks. Just remember that all the functions that are available via the DocumentParser will also be available when using MODxAPI:
<?php
$path = '/path/to/site/root/';
include_once($path.'modxapi.php');
$modx = new MODxAPI();
// connect to db and load settings
$modx->connect();
$modx->getSettings();
// to add your css chunks to the output use the following
// where Menu-StyleSheet should be replaced with the actual name of your css chunk
$html = $modx->getChunk('Menu-StyleSheet');
// this is where we call the DropMenu snippet
$html.= $modx->runSnippet(DropMenu,array('topnavClass'=>'nav', 'selfAsLink'=>'true'));
// now display the output :)
echo $html;
?>
@Scotty Delicious :
Can I use this for developing my snippets and modules without having to load modules through the manager to test/debug?
MODxAPI currently does not have any built-in feature that allows you you to easily create snippets and modules. You can still create snippets and modules but this would require some knowledge of the internals of the MODx system. For example, to create a snippet without using the manager you could currently have to do something like this:
$modx->snippetCache['MySnippet'] = 'Snippet Code goes here...';
$modx->runSnippet('MySnippet');
Thank you Xwisdom - it’s starting to work now - very interesting.