Blog Sections Open
Loading Evolution CMS Content with AJAX Without Breaking Chunks and TVs
The easiest AJAX shortcut in Evo is often the wrong one: fetching raw content and expecting the full template stack to come with it.
The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used The donor behind this post used If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment. If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page. If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject. AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only is not the same as rendering the full parsed page fragment.index-ajax.php and a small API bootstrap file to fetch a document by ID and return its content through AJAX. The important warning was already visible in the original text: returning only [*content*] is not the same as rendering the full parsed page fragment.The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>Better approach
The common mistake
If the loaded content depends on chunks, TVs, snippets, or parser-side placeholders, simply echoing the raw document content will not recreate the same result the browser sees in the fully rendered page.
Example bootstrap
<?php
define('MODX_API_MODE', true);
include_once 'manager/includes/config.inc.php';
include_once 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser;
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$modx->minParserPasses = 2;
$doc = $modx->getDocument($_POST['id']);
echo $doc['content'];
?>
Better approach
If the frontend expects parsed output, render the specific fragment intentionally. That may mean parsing a chunk, rendering a dedicated snippet, or building a response that already contains the HTML you actually want to inject.
AJAX should change transport, not content logic. If the browser needs the fully prepared fragment, return the fully prepared fragment.
Handling Very Large TV Option Lists in Evolution CMS
What to do when a TV field needs to represent a huge dataset and the default dropdown pattern stops being realistic for editors and performance.
Assigning Resource Aliases Automatically After Save in Evolution CMS
How to auto-assign a resource alias after the first save by using OnDocFormSave, and when that shortcut is useful for large editorial projects.