⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Displaying Record name while editing



abhishek

abhishek
  • profile picture
  • Member

Posted 09 May 2013 - 10:53 AM

Hi All

 

I want to display the name of the record in breadcrumb when i am editing a record.

Or we can also say i want to pass the name of record to view.

 

 

Ex:-  My  Breadcrumb looks like Home>>Projects>>EditProjects

But i want when i edit a particular record it should display Edit"ProjectName".

 

This is how i am creating the breadcrumbs

 <div id="breadcrumb">
        <a href="<?php echo ADMIN_SITE_URL.'projects'; ?>">Dashboard</a>
        <span class="pipe"> <?php echo '&rsaquo;&rsaquo;';  ?></span>
        <a href="<?php echo ADMIN_SITE_URL.str_replace(' ','',strtolower($subject));?>"><?php if(strtolower($subject) != 'record'): echo $subject; else: echo '&nbsp;'; endif; ?> </a>
        <span class="pipe"> <?php echo '&rsaquo;&rsaquo;';  ?></span>Edit <?php echo $subject;?>
         </div>

 


davidoster

davidoster
  • profile picture
  • Member

Posted 09 May 2013 - 11:06 AM

From your controller you pass on the view a variable with the project name.

Additionaly you can use get_state where you can differentiate the output of the breadcrumb depending on where you are.


abhishek

abhishek
  • profile picture
  • Member

Posted 09 May 2013 - 11:09 AM

How will i determine the name of the project..??
I want when a click on edit button against a particular record , then it should display name of record


davidoster

davidoster
  • profile picture
  • Member

Posted 09 May 2013 - 11:47 AM

I assume some sort of function produces the breadcrumb, if not then it is a good idea to have a function within your controller.

So we assume that we have something like this 

 

private function breadcrumb($level, $table, $id, $state)
{
$this->load->model('my_model');
$project_name = $this->my_model->get_project_name($table, $id);
if($state == 3) $operation = 'Edit';
return 'Home>>' . $level . '>>' . $operation . ' ' . $project_name;
}

public function my_controller()
{
$crud = new grocery_CRUD();
$subject = 'Project';
$crud->set_subject($subject);
...
...
$data['breadcrumb'] = $this->breadcrumb($subject . 's', 'projects', $this->uri->segments(3), $crud->getState());
$this->load->view('myview', $data);

}
 

For the model part check the manual.