I’ve tried the full version as well with no luck.
makeUrl(242, “”, “”, “full”);
It is as if I don’t have access to the modx classes. I’ve tried using runSnippet as well with no luck.
[2019-04-30 00:37:59] (ERROR @ /home/site/public_html/cms/core/xpdo/xpdo.class.php : 503) Path specified for package modResource is not a valid or accessible directory: /home/site/public_html/cms/core/model/modx/modresource.class.php
Checked permissions on this file and it is 0644 with directories to file being 0755 as expected.
with $url = $this->modx->makeUrl(25,‘’,‘’,‘https’); added in I just get a 500 error at the endpoint
From what I can tell you’re just trying to pull data from a TV and include it in the end point? If so then this should work for you. Just replace ‘tvname’ with the name of the TV you want to pull the data from.
<?php
class MyControllerResources extends modRestController {
public $classKey = 'modResource';
public $defaultSortField = 'id';
public $defaultSortDirection = 'ASC';
public function prepareListObject(xPDOObject $object){
$objectArray = $object->toArray();
$objectArray['fullUrl'] = $this->modx->makeUrl($objectArray['id'], "", "", "full");
$objectArray['locations'] = $this->object->getTVValue('tvname');
$objectArray['internationalLocations'] = $this->object->getTVValue('tvname');
return $objectArray;
}
}
return 'MyControllerResources';
You’re getting a 500 internal server error, so you need to look at your server error log for details.
Perhaps $this->modx isn’t a modX instance but an xPDO instance? That could explain why getObject works but not makeUrl. Perhaps the problem is that you need to first initialize/load a context before makeUrl can get to the context cache? The error in the server/php error log will hopefully provide answers, so we don’t have to guess.
This suggests you’re trying to load a package modResource, which indeed doesn’t exist. That might be coming from your index.php where you call $modx->addPackage()? The package for modResource is modx, and already automatically loaded when MODX is initialised. Could be useful if you also post your index file.