Welcome Guest, Not a member yet? Register   Sign In
How to implement CRUD in module (HMVC) ?
#1

[eluser]web_developer[/eluser]
Hello,

I want to develop one CMS for my client, and for that I have to prepare lots of modules with CRUD.

I have download the HMVC file and set it in library. But now how can I used that for add/edit/delete for particular module?

let's take one example

Code:
// MAIN PARENT CLASS //
class Home_page extends controller
{
  function Home_page()
  {
    parent::controller
  }

  function index()
  {
      $this->load->module('navigation');
  }
}

// MY MODULE CLASS //
//navigation/controller
//navigation/model
//navigation/view

ckass Navigation extends Controller
{
    function Navigation()
    {
       parent::controller;
      
       $this->load->model('navigationModel');
    }
    
    function add_navigation()
    {
       $this->navigationModel->add();
    }

    function remove_navigation()
    {
       $this->navigationModel->remove();
    }

    function edit_navigation()
    {
       $this->navigationModel->edit();
    }

    function show_navigation()
    {
       $this->navigationModel->show();
    }
}

So now how to set link for Add/edit/delete module? I means, I would like to load my module from any parent controller, then it should work.

I am not getting the proper way.. How to set link in view for Add/Edit/Delete and How can I access module in any parent class?

I hope you understand what I mean to say? Is there any tutorial or video for Module, which are using CRUD ? Can anyone help me in this?
#2

[eluser]vitoco[/eluser]
first some corrections in the code :
[quote author="web_developer" date="1274867793"]Hello,

Code:
...

// MY MODULE CLASS //
//navigation/controllers // FIXED
//navigation/models      // FIXED
//navigation/view        // FIXED

class Navigation extends Controller   // FIXED
{
...

So now how to set link for Add/edit/delete module? I means, I would like to load my module from any parent controller, then it should work.

I am not getting the proper way.. How to set link in view for Add/Edit/Delete and How can I access module in any parent class?

I hope you understand what I mean to say? Is there any tutorial or video for Module, which are using CRUD ? Can anyone help me in this?[/quote]

you don't have to "load" the module from a parent controller....just set the url to go the module controller... like this
Code:
base_url().'navigation/add_navigation/';
base_url().'navigation/remove_navigation/';
base_url().'navigation/edit_navigation/';
base_url().'navigation/show_navigation/';

// notice that if the controller inside the "navigation" module, have a different name
// like "navigation_2", the urls get like this

base_url().'navigation/navigation_2/add_navigation/';
base_url().'navigation/navigation_2/remove_navigation/';
base_url().'navigation/navigation_2/edit_navigation/';
base_url().'navigation/navigation_2/show_navigation/';

// so, only when the module name and the controller name are the same,
// you don't need to added to the url

this may help to load partials...
http://codeigniter.com/wiki/Modular_Extensions_-_FAQ/
#3

[eluser]web_developer[/eluser]
Thanks a lot, I was going wrong direction. But now I got it. Once again Thank you very much.
#4

[eluser]vitoco[/eluser]
i'm glad it helps, also...try to read all the documentation on the wiki about HMVC, cause there's a lot of tools that make the life easier.

Saludos




Theme © iAndrew 2016 - Forum software by © MyBB