We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Loading a view file in an accessory process function

Development and Programming

Chris Ruzin's avatar
Chris Ruzin
41 posts
14 years ago
Chris Ruzin's avatar Chris Ruzin

I’m making an accessory that can process an AJAX call. In the function that processes the call, I am trying to load a view file, but I’m getting a 500 internal server error instead.

This doesn’t work:

$out = $this->EE->load->view('available', $data, TRUE);
exit($out);

This doesn’t work:

exit($this->EE->load->view('available', $data));

This does work:

$out = 'Hi there!';
exit($out);

I saw that there was a previous thread about this issue, and that it was marked as a bug which was apparently resolved in EE 2.1.1. Am I missing something here or is this still not working?

EDIT: Forgot to mention I’m using EE 2.1.3.

       
Chris Ruzin's avatar
Chris Ruzin
41 posts
14 years ago
Chris Ruzin's avatar Chris Ruzin

This is apparently a known issue for the current 2.1.3 build (20110411). I fixed it by changing line 211 and 213 in system/expressionengine/controllers/cp/addons_accessories.php from:

$this->load->add_package_path(PATH_THIRD.strtolower($class).'/');
...
$this->load->_ci_view_path = PATH_THIRD.strtolower($class).'/views/';

to:

$this->load->add_package_path(PATH_THIRD.strtolower($name).'/');
...
$this->load->_ci_view_path = PATH_THIRD.strtolower($name).'/views/';

Thanks go to Greg Ferrell for the quick fix!

       
Chris Ruzin's avatar
Chris Ruzin
41 posts
14 years ago
Chris Ruzin's avatar Chris Ruzin

Another fix is to set the path in my accessory, and then once I’m done, set it back.

$orig_view_path = $this->EE->load->_ci_view_path;
$this->EE->load->_ci_view_path = PATH_THIRD.'accessory_name/views/';

*Process the view file*
$this->EE->load->_ci_view_path = $orig_view_path;
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.