alexatkeplar Reply #1, 1 year, 10 months ago
Hi,
I didn't find a post on how to use Zend Framework libraries from within MODx (Evo), so thought I would just post a quick howto here:
1. DL the Zend Framework libraries from http://framework.zend.com/download/latest (you just need the Minimal install)
2. Unzip them to a path e.g. /var/www/libraries/Zend (you just need the contents of the library folder from the zip)
3. Create a new snippet called zend.inc.php in a folder called zend with the following contents:
4. Now in a MODx snippet you can use Zend like so:
Hope this is helpful! Let me know if it is and I'll post another howto on integrating MaxMind geo-IP with MODx...
I didn't find a post on how to use Zend Framework libraries from within MODx (Evo), so thought I would just post a quick howto here:
1. DL the Zend Framework libraries from http://framework.zend.com/download/latest (you just need the Minimal install)
2. Unzip them to a path e.g. /var/www/libraries/Zend (you just need the contents of the library folder from the zip)
3. Create a new snippet called zend.inc.php in a folder called zend with the following contents:
<?php
/**
* This is a Zend Framework loader for MODx Evolution
* Author: Alex Dean @alexatkeplar
*/
define('LIBRARY_PATH', '/var/www/libraries/'); // Update as appropriate
// First make sure the Zend library is in the include path:
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . LIBRARY_PATH);
// Then require the Autoloader class:
require_once 'Zend/Loader/Autoloader.php';
// Instantiate the loader
$loader = Zend_Loader_Autoloader::getInstance();
4. Now in a MODx snippet you can use Zend like so:
<?php require_once($modx->config['base_path'] . 'assets/snippets/zend/zend.inc.php'); $userLocale = new Zend_Locale(Zend_Locale::BROWSER); // Or whatever... $userLanguage = $userLocale->getLanguage();
Hope this is helpful! Let me know if it is and I'll post another howto on integrating MaxMind geo-IP with MODx...