// Internal variable which holds the set of IDs where to look for $IDs = ($idType == "parents") ? $parents : $documents; $listIDs = getListIDs($IDs, $idType, $depth);
In the current version of AS, the complete IDs list is transmitted thru javascript. Rather to transmit a long list of ID, I would like transmit only the parents Ids. But This required to use the $Modx->documentMap function in the Php script called from the ajax script.<?php
// MODx Location
$base_path = '/Users/webdev/Sites/MODx/';
// Snippet to run tests on
$snippet_name = 'EventCalendar';
// End Configuraiton
//////////////////////
if (!isset($snippet_params)) $snippet_params = array();
// Setup the MODx API
define('MODX_API_MODE', true);
include_once($base_path.'index.php');
$modx->db->connect();
$modx->getSettings();
// We're ready to go!
$output = $modx->runSnippet($snippet_name, $snippet_params);
1/ For now, if you prefer to use the modx object in your separate Ajax script, you can use a technique that netnoise introduced in 0.9.6.1, which allows you to include the main index.php file, which initializes the modx object for usage, and prevents the executeParser() method from being called. 2/ Personally, I’d rather see the ajax request itself served by an additional snippet, distributed with the AjaxSearch add-on, that can simply be configured on another page (that likely would not be shown on a menu; i.e. a document serving as an Ajax service). This is how I implement all ajax requests in my MODx sites.
I plan to include in ajaxSearch.php code the following lines:
// Setup the parameters and make the ajax call
var pars = Object.toQueryString({
q: _base + ’ajaxSearch.php’,
search: s,
as_version: as_version,
debug: debug,
ajaxMax: ajaxMax,
…
hideMenu: hideMenu,
listIDs: listIDs
});
var ajaxSearchReq = new Ajax(’index-ajax.php’, {postBody: pars, onComplete: doSearchResponse});
if (newToggle.isDisplayed()) {
newToggle.toggle();
ajaxSearchReq.request.delay(600, ajaxSearchReq);
} else {
ajaxSearchReq.request();
}
// Setup the MODx APIAnd then use modx->documentMap function to get all the list IDs from the &parents.
define(’MODX_API_MODE’, true);
// initiate a new document parser
include_once(MODX_MANAGER_PATH.’/includes/document.parser.class.inc.php’);
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
// Setup the MODx API
define('MODX_API_MODE', true);
// initiate a new document parser
include('/path/to/index.php');
// Setup the parameters and make the ajax call
var pars = Object.toQueryString({
q: '[~ajaxDocId~]',
search: s,
as_version: as_version,
debug: debug,
ajaxMax: ajaxMax,
…
hideMenu: hideMenu,
listIDs: listIDs
});
var ajaxSearchReq = new Ajax('[~ajaxDocId~]', {postBody: pars, onComplete: doSearchResponse});
if (newToggle.isDisplayed()) {
newToggle.toggle();
ajaxSearchReq.request.delay(600, ajaxSearchReq);
} else {
ajaxSearchReq.request();
}
Jason, this only initializes the [tt]$modx[/tt] object. The [tt]$modx->documentMap[/tt] array is not populated (because it is stored in [tt]siteCache.idx.php[/tt]) until the [tt]getSettings()[/tt] method is called. That is, unless we’re talking about 0.9.7 in which case I need to shut up :-/
First, this is all you need to get access to $modx...
// Setup the MODx API define('MODX_API_MODE', true); // initiate a new document parser include('/path/to/index.php');
And presto, $modx->documentMap is available.

Well, hello kylej! And my apologies, I didn’t mean my comment as a crack at your thinking when originally implementing it. In fact the reason I believe was to keep the request as trim as possible. I think though if having the $modx object available is needed to meet functional requirements, it will be just as efficient to do it as a MODx document/snippet.
@Jason - is wasn’t done that way because I wasn’t thinking clearly (and I don’t think I had seen that done at the time)