1

デフォルトとは異なるフォルダーからコントローラーとモデルをロードする必要があります。Linux システムを使用しています。

私が所有する共有ホスティングで使用するために、一部の人々向けの単純な CI アプリケーションを構築しています。しかし、/views フォルダーといくつかの /config ファイルへのアクセスのみを許可したいと考えています。これが、コントローラーとモデルを /public_html フォルダーと同じレベルの別のフォルダー、または Linux システムのどこかに保存する必要がある理由です。

これは、ファイルをエンコードするよりも優れたソリューションになると思います

4

1 に答える 1

0

CodeIgniter permits you to organize your controllers,views and config files into sub-folders. As far as I know it doesn't permit it for models (at least documentation doesn't mention it, I've not tried myself).

As your are in a Linux system, you can create a symbolic link to reference to another directory in the filesystem.

So you can create the directories:

application/config/public
application/controllers/public
application/views/public

And then create in your /public_html symbolic links ponting to these directories:

/public_html/config -> application/config/public
/public_html/controllers -> application/controllers/public
/public_html/views ->application/views/public

When your customers upload files to /public_html/config, they will be also available in application/config/public. The same applies for /public_html/controllers and /public_html/views.

The command syntaxis to creates symlinks is

# ln -s target name

i.e:

# ln -s application/config/public /public_html/config

If you don't have console access to your hosting you can create the links using the PHP function symlink() .

To load a view/config/controller from a subfolder you only have tu prepend the directory name in the $this->load->...() function call. i.e:

$this->load->view('public/my_view);

Check CI documentation for more info about organizing your files into sub-folders.

于 2010-06-16T21:47:01.150 に答える