All Projects → jamierumbelow → Codeigniter Base Controller

jamierumbelow / Codeigniter Base Controller

Licence: mit
⛔️DEPRECATED CodeIgniter base controller with view autoloading and layout support

Projects that are alternatives of or similar to Codeigniter Base Controller

Aawindow
[Deprecated] · UIWindow subclass to enable behavior like adaptive round-corners & detecting when Control Center is opened.
Stars: ✭ 486 (+322.61%)
Mutual labels:  deprecated, archived, obsolete
Graphql Modules
⚠️ [DEPRECATED] GraphQL module library for Apollo.
Stars: ✭ 53 (-53.91%)
Mutual labels:  deprecated, archived, obsolete
Sphero.js
🚫 DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.
Stars: ✭ 346 (+200.87%)
Mutual labels:  deprecated, archived, obsolete
Docker Cleanup
DEPRECATED Automatic Docker image, container and volume cleanup
Stars: ✭ 582 (+406.09%)
Mutual labels:  deprecated, archived, obsolete
Codeigniter Schema
⛔️DEPRECATED Expressive table definitions
Stars: ✭ 87 (-24.35%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Prefabs
*Deprecated* - A collection of productive prefabs for rapidly building spatial computing solutions in the Unity software.
Stars: ✭ 61 (-46.96%)
Mutual labels:  deprecated, archived, obsolete
Pygeoip
DEPRECATED: Pure Python API for Maxmind's binary GeoIP databases
Stars: ✭ 483 (+320%)
Mutual labels:  deprecated, archived, obsolete
Sphero-AR-SDK
🚫 DEPRECATED: Sphero's augmented reality SDK
Stars: ✭ 46 (-60%)
Mutual labels:  deprecated, archived, obsolete
Closure Linter
Automatically exported from code.google.com/p/closure-linter
Stars: ✭ 104 (-9.57%)
Mutual labels:  deprecated, archived, obsolete
Tinx
⛔️ Laravel Tinx is archived and no longer maintained.
Stars: ✭ 437 (+280%)
Mutual labels:  deprecated, archived, obsolete
Mern Cli
⛔️ DEPRECATED - A cli tool for getting started with MERN
Stars: ✭ 575 (+400%)
Mutual labels:  deprecated, archived, obsolete
Secretary
DEPRECATED Secrets management for dynamic environments
Stars: ✭ 93 (-19.13%)
Mutual labels:  deprecated, archived, obsolete
react-native-apple-sign-in
Apple Signin for your React Native applications
Stars: ✭ 16 (-86.09%)
Mutual labels:  deprecated, archived, obsolete
Mern Starter
⛔️ DEPRECATED - Boilerplate for getting started with MERN stack
Stars: ✭ 5,175 (+4400%)
Mutual labels:  deprecated, archived, obsolete
AASecondaryScreen
[Deprecated] · Approachable implementation of iOS AirPlay-Mirroring using Swift.
Stars: ✭ 40 (-65.22%)
Mutual labels:  deprecated, archived, obsolete
Piranha
[DEPRECATED] This is the legacy version of Piranha CMS for .NET 4.5, MVC 5.2 & WebPages 3.2.
Stars: ✭ 418 (+263.48%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Tutorials.OculusIntegration
Prefabs and code for use with the Oculus Integration Unity Package
Stars: ✭ 26 (-77.39%)
Mutual labels:  deprecated, archived, obsolete
QR
DEPRECATED The bookmarklet and extensions generate QRCode of the current URL for viewing on mobile devices (Google Chrome/Mozilla Firefox/Opera/Safari)
Stars: ✭ 20 (-82.61%)
Mutual labels:  deprecated, archived, obsolete
Codeigniter Base Model
⛔️DEPRECATED CodeIgniter base CRUD model to remove repetition and increase productivity
Stars: ✭ 1,052 (+814.78%)
Mutual labels:  deprecated, archived, obsolete
Sphero Mac Sdk
🚫 DEPRECATED: Sphero SDK for the Mac platform.
Stars: ✭ 70 (-39.13%)
Mutual labels:  deprecated, archived, obsolete

DEPRECATED: codeigniter-base-controller

Deprecated since I no longer use CodeIgniter. If anybody would like to take over maintainence of this repo, please get in touch.

No Maintenance Intended Build Status

codeigniter-base-controller is an extended CI_Controller class to use in your CodeIgniter applications. Any controllers that inherit from MY_Controller get intelligent view autoloading, layout support and asides/partials. It's strongly driven by the ideals of convention over configuration, favouring simplicity and consistency over configuration and complexity.

Synopsis

class Users extends MY_Controller
{
    protected $models = array( 'user', 'group' );

    protected $helpers = array( 'cookie', 'file' );

    public function index()
    {
        $this->data['users'] = $this->user->get_all();
    }

    public function show($id)
    {
        if ($this->input->is_ajax_request())
        {
            $this->layout = FALSE;
        }

        $this->data['user'] = $this->user->get($id);
        $this->data['groups'] = $this->group->get_all();
    }
}

Usage

Drag the MY_Controller.php file into your application/core folder. CodeIgniter will load and initialise this class automatically for you. Extend your controller classes from MY_Controller and the functionality will be available automatically.

Views and Layouts

Views will be loaded automatically based on the current controller and action name. Any variables set in $this->data will be passed through to the view and the layout. By default, the class will look for the view in application/views/controller/action.php.

In order to prevent the view being automatically rendered, set $this->view to FALSE.

$this->view = FALSE;

Or, to load a different view than the automatically guessed view:

$this->view = 'some_path/some_view.php';

Views will be loaded into a layout. The class will look for an application/views/layouts/controller.php layout file; if it can't be found it will fall back to an application/views/layouts/application.php file, which is the defacto, application-wide layout.

In order to specify where in your layout you'd like to output the view, the rendered view will be stored in a $yield variable:

<h1>Header</h1>

<div id="page">
    <?= $yield ?>
</div>

<p>Footer</p>

If you wish to disable the layout entirely and only display the view - a technique especially useful for AJAX requests - you can set $this->layout to FALSE.

$this->layout = FALSE;

Like with $this->view, $this->layout can also be used to specify an unconventional layout file:

$this->layout = 'layouts/mobile.php';

Any variables set in $this->data will be passed through to both the view and the layout files, as well as any asides.

Asides

Asides are a great way to insert variable content into your layouts that might need to change on an action by action basis. This is especially helpful when you want to load sidebars or render separate forms of navigation.

Asides are arbitrary views loaded into variables. They can be set using the $this->asides variable:

protected $asides = array( 'sidebar' => 'users/_sidebar' );

They're then exposed as $yield_ variables in the layout:

<div id="sidebar">
    <?= $yield_sidebar ?>
</div>

Any variables in $this->data will be passed through to the sidebar.

Model Loading

You can specify a list of models to load with the $this->models variable:

protected $models = array( 'user', 'photograph', 'post' );

The model name is based on the $this->model_string variable. This allows you to name your models however you like. By default, the model string is:

protected $model_string = '%_model';

The percent symbol (%) will be replaced with the model name in the $this->models array. It will then be loaded into the CI object under the declared name.

protected $models = array( 'user' );

public function index()
{
    // $this->load->model('user_model', 'user');
    $this->user->get(1);
}

If, for example, you name your models model_user, you can specify the model string:

protected $models = array( 'user' );
protected $model_string = 'model_%';

public function index()
{
    // $this->load->model('model_user', 'user');
    $this->user->get(1);
}

Helper Loading

You can specify a lost of helpers to load with the $this->helpers variable:

protected $helpers = array( 'cookie', 'file', 'xml' );

Per-controller 404 override

Before CodeIgniter throws a standard 404, MY_Controller will look for a _404 method on the controller. This allows you to customise the output of the 404 page on a controller-by-controller basis.

Changelog

Version 1.3.0 - IN DEVELOPMENT

  • Vastly improved documentation
  • Added unit test suite
  • Added helper autoloading

Version 1.0.0 - 1.2.0

  • Initial Release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].