LoginSignup
4
5

CodeIgniterからMODx API (MODx Evolution)を利用する方法

Last updated at Posted at 2015-04-08

以下のようなコードを追加することで、CodeIgniterからMODx Evolutionで作成されたリソース、チャンクなどを呼び出せるようになります。
#コード
以下の内容をCodeIgniterのindex.phpに追加します。

/index.php
$modx_dir = '/MODxのインストール先ディレクトリ/';
define('MODX_API_MODE', true);
include($modx_dir . 'index.php');

以下のようなライブラリを追加します。

/application/libraries/lib_modx_api.php
//if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class lib_modx_api extends DocumentParser {
    public function __construct() {
       parent::__construct();
    }
}

#使用例
リソースID1の本文(content)を出力したい場合の例

example.php
class example extends CI_Controller {
    function __construct()
    {
        parent::__construct();
        $this->load->library('lib_modx_api');
    }
    function index() {
        $result['content'] = $this->lib_modx_api->getField('content', 1);
        $this->load->view('example', $result);
    }
}

#注意点
MODxはGPLv2であるが、CodeIgniter2はOSL3.0で、ライセンスは非互換とされているため、この使い方はライセンス違反になる恐れがありますので注意が必要です。
CodeIgniter3はMITライセンスのため問題ないと思います。

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5