$page = $modx->getObject('modResource', $id);
$fileUrl = $page->getSourceFile();
$filePath = MODX_BASE_PATH . $filePath; // or if you really want a URL $fileUrl = MODX_BASE_URL . $filePatch;
$options = array(); $options['resource_static_path'] = 'some/path'; $filePath = $page->getSourceFile($options);
/**
* Get the absolute path to the static source file represented by this instance.
*
* @param array $options An array of options.
* @return string The absolute path to the static source file.
*/
public function getSourceFile(array $options = array()) {
if (empty($this->_sourceFile)) {
$filename = parent :: getContent($options);
if (!empty($filename)) {
$array = array();
if ($this->xpdo->getParser() && $this->xpdo->parser->collectElementTags($filename, $array)) {
$this->xpdo->parser->processElementTags('', $filename);
}
}
if (!file_exists($filename)) {
$this->_sourcePath= $this->xpdo->getOption('resource_static_path', $options, $this->xpdo->getOption('base_path'));
if ($this->xpdo->getParser() && $this->xpdo->parser->collectElementTags($this->_sourcePath, $array)) {
$this->xpdo->parser->processElementTags('', $this->_sourcePath);
}
$this->_sourceFile= $this->_sourcePath . $filename;
} else {
$this->_sourceFile= $filename;
}
}
return $this->_sourceFile;
}$path = str_replace(MODX_BASE_URL, MODX_BASE_PATH, $url);