moabi:
Instead I do this :
//set pathToUrl second parameter to TRUE allow us to have the full URL
// This works for the style, but not for the scripts, maybe a cache issue
$list[] = '<link href="'.($ispath ? $this->pathToUrl($src, true):$src).($version ? "?ver={$version}":"").'" type="'.$type.'" rel="'.$rel.'">';
You shouldn’t modify App.php
directly. It could cause other issues in hidden places and it will be overwritten with the next update.
But for a better understanding - the assets function splits into two functions: style()
and script()
. If you want to modify it that way, you have to adjust that line, too:
/**
* Run Application
* @param String $route Route to parse
* @return void
*/
public function run($route = null, $request = null, $flush = true) {
$self = $this;
if ($route) {
$this->registry['route'] = $route;
}
if ($request) {
$this->request = $request;
}
if (!isset($this->request)) {
$this->request = $this->getRequestfromGlobals();
}
It’s hard to find the right way without the same setup… Some more hints:
Maybe this collection of paths, constants and function dependencies helps a bit.
I had a case, where I didn’t want to change the constants, but only a few registry entries and a filestorage url. In this case, I use Cockpit as backend at example.com/cockpit
and use the same folder as a library in my frontend. The problem feels similar, but I didnt’t use any symlinks. So, maybe it helps for inspiration:
$MP_DOCS_ROOT = str_replace(DIRECTORY_SEPARATOR, '/', isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : dirname(__DIR__));
# make sure that $_SERVER['DOCUMENT_ROOT'] is set correctly
if (strpos(MP_DIR, $MP_DOCS_ROOT)!==0 && isset($_SERVER['SCRIPT_NAME'])) {
$MP_DOCS_ROOT = str_replace(dirname(str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['SCRIPT_NAME'])), '', MP_DIR);
}
if (!defined('MP_DOCS_ROOT')) define('MP_DOCS_ROOT', $MP_DOCS_ROOT);
$BASE_URL = dirname(parse_url($_SERVER['SCRIPT_NAME'], PHP_URL_PATH));
if (!defined('MP_BASE_URL')) define('MP_BASE_URL', $BASE_URL === '/' ? '' : $BASE_URL);
if (!defined('MP_ENV_ROOT')) define('MP_ENV_ROOT', MP_DIR);
if (!defined('MP_ENV_URL')) define('MP_ENV_URL', MP_DIR == MP_ENV_ROOT ? MP_BASE_URL : MP_BASE_URL . str_replace(MP_DIR, '', MP_ENV_ROOT));
if (!defined('MP_CONFIG_DIR')) define('MP_CONFIG_DIR', MP_ENV_ROOT.'/config');
// avoid overriding paths and don't bind routes - to do: cleaner implementation
if (!defined('MP_SELF_EXPORT')) define('MP_SELF_EXPORT', false);
// for thumbnails of CpMultiplane assets
if (!defined('COCKPIT_SITE_DIR')) define('COCKPIT_SITE_DIR', MP_ENV_ROOT);
define('MULTIPLANE_VERSION', '0.3.5');
if ($this['debug']) \error_reporting(E_ALL);
// shorthand module call
if (!function_exists('mp')) {
function mp() {return cockpit('multiplane');}
}
// define some constants to avoid throwing errors if Multiplane is inside
// `addons` dir of cockpit instead of inside `modules` dir of CpMultiplane
if (!defined('MP_ADMINFOLDER')) define('MP_ADMINFOLDER', '');
You could change it