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

Custom Functionality the EE way

Development and Programming

Sanity11's avatar
Sanity11
314 posts
15 years ago
Sanity11's avatar Sanity11

Hiya,

I am starting a project where on one part of the website is a section where clients can update their personal information. The personal information has nothing to do with site members or anything EE related.

The client information is going to be stored in a custom table in the database.

Next this means I need a page with a login form, and if the information is correctly submitted a page with the user info that can be changed. I have a couple ideas on how to do this. But what would be the way to this with EE. I know i’ts CI powered, and I know how to use CI, but I am not entirely understanding how to use it in EE for this kind of functionality?

Can I make something like a model, controller and view like I would while building a CI only app, or do I need a completely different approach?

Thanks!

[Mod Edit: Moved to the Development and Programming forum]

       
Sanity11's avatar
Sanity11
314 posts
15 years ago
Sanity11's avatar Sanity11

Ok, found some info here:http://ellislab.com/forums/viewthread/173649/

But the barebone controller leaves a blank page:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Test Controller
 *
 * @package default
 * @author Jesse Bunch
 **/
class Test extends Controller {

    /**
     * Construct
     */
    function Test()
    {        
        parent::Controller();
        
        // Calls the EE & CI initialization
        $this->core->_initialize_core();
        $this->EE =& get_instance();
    }

    // --------------------------------------------------------------------

    /**
     * Index
     */
    function index()
    {
        $this->load->view('test');
    }

}

/* End of file test.php */
/* Location: ./system/expressionengine/controllers/test.php */

Right now I am using this, but I would like to use a “normal” constructor.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contact_checker extends CI_Controller
{    
    private $data = array();
    
    public function construct()
    {
        $this->load->model('contact_checker_model');
        $this->data = $this->contact_checker_model->general_data();
    }
    
    public function show_page()
    {
        $this->construct();
        
        $this->load->view('contact_checker_view', $this->data);
    }
}


?>
       
Sanity11's avatar
Sanity11
314 posts
15 years ago
Sanity11's avatar Sanity11

Anyone, I am really stuck on this. I have no Idea why the view doesn’t seem to be loading….

       
Barry Cogan's avatar
Barry Cogan
291 posts
15 years ago
Barry Cogan's avatar Barry Cogan

Hi Sanity,

Well the reason you are getting blank pages for your custom controller is because it is using the outdated constructor format.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Test Controller
 *
 * @author Barry Cogan
 **/
class Test extends CI_Controller {

    /**
     * Constructor
     */
    // PHP 5+ prefers use of __construct() instead of classname()  This is required to work in EE 2
    function __construct()
    {        
        // Call the CI_Controller's Constructor
        parent::__construct();
        
        // Calls the EE & CI initialization
        $this->core->_initialize_core();
        $this->EE =& get_instance();
    }

    // --------------------------------------------------------------------

    /**
     * Index
     */
    function index()
    {
        // load a view from ./system/expressionengine/views/
        $this->load->view('test');  // ./system/expressionengine/views/test.php
    }

}

/* End of file test.php */
/* Location: ./system/expressionengine/controllers/test.php */

You will run into some issues doing this though. I am failing to see why you don’t just go ahead and make a set of templates for that specific parts of the site. You could use safecracker add-on for the necessary form information. I believe this would save you headaches down the line as modifying the core like that will prevent you from easily updating the software in the future.

Best regards, Barry

       
Sanity11's avatar
Sanity11
314 posts
15 years ago
Sanity11's avatar Sanity11

Hi Barry,

Thanks! That should do it. I didn’t know about safecracker. But it’s not that hard or anything, things are up and running smoothly.

       
Barry Cogan's avatar
Barry Cogan
291 posts
15 years ago
Barry Cogan's avatar Barry Cogan

Delighted to hear it! 😊

       

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.