Hello all,
I’ve seen a few topics about this but nothing definitive, so I’m wondering if anyone can provide some direction for me.
I am currently running a CI application that is integrated with an external API.
Recently a new requirement has arisen whereby we need to be able to manage content on this application. I was hopeful that I could use EE to manage the content and then integrate the content into my existing application.
Specifically I’m hoping for the following:
The CI application is moderately complex (at least) and so re-writing it to work under the template system of EE is less than ideal.
I wouldn’t take issue over writing a module/plugin to accomplish what I need, but I want to make sure I can achieve what I’m after before digging in.
Any help is very much appreciated.
Moved to Development and Programming by Moderator
Hello again,
I just wanted to follow up on my original posting.
It has been over two weeks and I have yet to receive a reply. For a company that advertises ‘world-class technical support’ this is a quite disappointing.
If what I am trying to achieve is not possible I would at least expect a response indicating that that is the case.
As a paying customer using the recommended channels for support, I expect better.
It has been over two weeks and I have yet to receive a reply. For a company that advertises ‘world-class technical support’ this is a quite disappointing.
Unfortunately what you are looking for is somewhat beyond the scope of regular Tech Support (which is the reason why Sue moved your thread in the first place). We have quite a few talented programmers in our community, though, so lets hope one of them chimes in 😊 Thanks.
Open up index.php, and find these lines and comment them out:
$routing['directory'] = '';
$routing['controller'] = 'ee';
$routing['function'] = 'index';Now you will be able to access other CI controllers aside from the default ee controller. You can now create your own custom controllers and views, placing them in /system/expressionengine/controllers/ and /system/expressionengine/views/, and access your controllers normally, ie http://yoursite.com/index.php/controller.
In your controllers, you can use the channel_entries_model and the other EE specific models to get at your data.
Hope this helps you get started 😊
>> In your controllers, you can use the channel_entries_model and the other EE specific models to get at your data.
Rob - Is this via the API? (Channel Entries)
There are models AND there are the APIs. I’m not entirely sure of the distinction; I think models are more for retrieving data and APIs are more for manipulating? I’d look at the source for both, they’re all very useful. /system/expressionengine/models/ and /system/expressionengine/libraries/api/
From what I have read (silly as it seems) the API’s do not perform read functions. Only write ones.
I have been able to get simple queries working by configuring my CI application to look at the EE DB (this assumes both applications exists on the same server) as well as taking a copy of the channel_entries_model and putting it inside of my CI application.
The results are quite nice, however I have so far been unable to get my custom fields back with useful names.
Looking at the exp_channel_data table in the DB (where your content actually lives) all of your content is stored in indexed fields like field_id_1, field_id_2… field_id_n. When I use the model directly, I am forced to read the data as
echo $row['field_id_1'];What I would like to use is:
echo $row['custom_field_name'];My understanding so far is that EE maps ‘field_id_n’ to a useful name inside of the channels model AFTER the data has been read from the DB.
Follow up:
I’m testing how this should work and have run into a snafu.
I edited the ‘index.php’ file as described above. Commented out the 3 lines.
I copied ‘welcome.php’ controller from a new CI install to /system/expressionengine/controllers/
I copied ‘welcome_message.php’ view from a new CI install to /system/expressionengine/views/
I used ‘domain/index.php/welcome/’ to access the page.
Browser displays and empty page. The ‘welcome_message’ page doesn’t display.
Can someone tell me what I’m missing?
Thanks,
Randy
EDIT:
I had to remove the Welcome function from ‘welcome.php’ to get it working. More testing…
Ah,
I am in a similar spot. I have followed this blog post: http://paramoreredd.com/blog/entry/harnessing-the-power-of-codeigniter-in-expressionengine-2.0/
and everything seems correct by I just get 404s or the default view for the site. Did you succeed completely? It seems given that ee is now built on ci that it should be front and center how to call a ci controller from a ee install. I am a ci developer and this is why I chose ee. Any other hidden gotchas? htaccess? Any further discussion / tips on this topic would be greatly appreciated.
I would love to know more about this as well. Any love out there? I started a topic here that could be resolved with this methodology, I hope. When I follow the steps above, the browser renders a blank white screen, then checking source code, there is also nothing …. oh, before posting this reply I thought a bit more and modified my test controller code and the basics seem to be working!
Follow the instructions from Jesse Bunch’s Blog article. However, you need to modify some of Jesse’s code in the class definition and the constructor. The CI_ prefix of the extended controller was introduced with CI2. Anyway, I commented out my changes before the amendments, something like this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// class Test_controller extends Controller
class Test_controller extends CI_Controller {
function __construct()
{
// parent::Controller();
// parent::CI_Controller();
parent::__construct();
// Initialize ExpressionEngine objects
$this->core->_initialize_core();
$this->EE =& get_instance();
}
function index()
{
// echo 'hi there';
$this->load->view('test_view');
}
}Will someone with more knowledge chime in here to confirm the above, as there can be errors php notices and warnings when initializing the EE objects in the constructor. Cheers. B.
However, there will be other issues with CI handling the view instead of an EE handling the template. Such as, EE parsing of something like the following will not be available:
{if member_group == '1'}
do this ...
{/if}This type of logic will may need to be moved into the controller for my needs (which is sort of the reverse of the initial poster’s) I suppose. In other words, I need to figure out how to use EEs authentication in the test controller to proceed with certain code or redirect elsewhere.
if ($this->EE->session->userdata['group_id'] != '1')
{
$data['test'] = 'NOT a superadmin, no access here, exit and redirect';
$this->load->view('test_view', $data);
}Anyway, this should help move in the right direction.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.