Hello Everyone, I have an issue with parse chunk not parsing the [[~[[id]]]] links within my chunks in ModX Revolution 2.0.7.
I am trying to use a modx chunk in a php file that is external to modx. I have used the following code to connect to the modx api from an external file:
<?php
//modx object - test
require_once 'manager/config.core.php';
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
//tim's code:
define('MODX_SITE_BASE_URL', 'http://my website here.co.uk/');
// The MODx document we are going to pretend to be
define('MODX_DOCUMENT_IDENTIFIER', 15);
// Some defines used by the modx API
define('MODX_API_MODE', true);
define('MODX_SITE_URL', (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off' ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].MODX_SITE_BASE_URL);
// Run the MODx config and get site settings
require(MODX_MANAGER_PATH.'/../index.php');
$modx->getSettings();
// Set the docid (most sensibly to the MODx weblink to here) and get the MODx document object
$modx->documentObject = $modx->getDocumentObject('id', MODX_DOCUMENT_IDENTIFIER);
$modx->documentIdentifier = MODX_DOCUMENT_IDENTIFIER;
// Set the base URL for any MODx snippets
$modx->config['base_url'] = MODX_SITE_BASE_URL;
//END Tim's code
?>
The chunk itself (named ’foot’) looks like this:
<a href="[[~[[1]]]]">Home</a> | <a href="[[~[[2]]]]">About</a> | <a href="[[~[[3]]]]">Contacts</a> | <a href="[[~[[4]]]]">Public Courses</a> | <a href="[[~[[5]]]]">Testimonials</a> | <a href="[[~[[61]]]]">Book Here</a> | <a href="[[~[[7]]]]">Terms and Conditions</a> | <a href="[[~[[8]]]]">Privacy Policy</a>
And have used the following getChunk function to get the chunk:
echo $modx->getChunk('foot',array());
The corresponding code output from the getChunk function looks like this (Note: The URL’s have not been processed)
<a href="">Home</a> | <a href="">About</a> | <a href="">Contacts</a> | <a href="">Public Courses</a> | <a href="">Testimonials</a> | <a href="">Book Here</a> | <a href="">Terms and Conditions</a> | <a href="">Privacy Policy</a>
[[~[[1]]]] should return the url to the resource 1.
I have tried using the parsechunk function to fix it but have had no joy. I have also done a fair amount of searching and have so far been unsuccessful.
I must be missing a function call or have the procedure of managing chunks externally completely wrong. I would really appreciate it if any of you could resolve this for me.