<?php $basePath = dirname(dirname(dirname(dirname(dirname(dirname( __FILE__ )))))); require_once $basePath . '/config.core.php'; require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'; require_once MODX_CONNECTORS_PATH . 'index.php'; $modx->request->handleRequest( array( 'processors_path' => $modx->getOption( 'core_path' ) . 'components/gallerygear/processors/', 'location' => 'photo' ) );
<?php /* initialize the proper context */ $ctx = isset($_REQUEST['ctx']) && !empty($_REQUEST['ctx']) ? $_REQUEST['ctx'] : 'mgr'; $modx->initialize($ctx);
<?php include_once ($modx->getOption('core_path') . "components/gallerygear/gallerygear.class.php"); $gg = new GalleryGear(); $resizedPhoto = $modx->getObject('ggResizedPhoto', $_REQUEST['key']); $pathFile = $resizedPhoto->getPathFile(); if($pathFile) { header('Content-type: ' . $resizedPhoto->getContentType()); return file_get_contents($pathFile); } else { return 'No such file.'; }
$modx->request->handleRequestThe request handler is different for back end and front end. The back end(mgr) context uses the modmanagerRequest/Response classes while the front end(web) uses the modRequest/Response classes. The front end doesn’t execute processors, it looks for a page to get(id=xx).
$connectorRequestClass = $modx->getOption(’modConnectorRequest.class’,null,’modConnectorRequest’);This sets the request class to modConnectorRequest, which is an extension of modmanagerRequest so you are using this class not the front end class.
$modx->config[’modRequest.class’] = $connectorRequestClass;
I’m not sure what you are trying to do hereIt’s for a gallery system. [Revolution Third Party Component] GalleryGear It outputs a resized version of a photo if it’s needed. Let’s say you have a page on which you use fancybox. You don’t need all the big photos at once. This saves some page loading time and I have the ability to count the views. Is what I’m trying to achieve possible if I load modx externally in a php script?
<a href="... .php?key=..." class="fancybox"> <img src="image.jpg" /> </a>