Codeigniter view function changes to $ template

I currently have the following function, but I would like to change it to a "template", using after , but I'm not sure what the best way to achieve my goal is:

The reason for this is because I need to use the WYSIWYG administrative fragment append_metadata($this->load->view('fragments/wysiwyg', array(), TRUE)) in my product_get_details function.

Code:

  public function ajax_product_get_details($product_id = NULL) { if(isset($_POST['id'])) { $product_id = $_POST['id']; } $table = SITE_REF.'_ps_products'; $data['product_details'] = $this->Ps_products_model->table_get_row($table, $product_id); $data['assoc_categories'] = $this->Ps_products_model->product_get_x_categories($product_id); $data['parent_categories'] = $this->Ps_products_model->categories_get_parent_list(); $data['folders'] = $this->file_folders_m->get_folders(); $table_man = SITE_REF.'_ps_products_manufacturers'; $data['manufacturers'] = $this->Ps_products_model->table_get_all($table_man, 'name', 'asc'); $this->load->view('admin/ajax/admin_product_details', $data); } 

Index Function:

  public function index() { $this->template ->title($this->module_details['name']) ->append_js('jquery/jquery.ui.nestedSortable.js') ->append_js('jquery/jquery.stickyscroll.js') ->append_metadata($this->load->view('fragments/wysiwyg', array(), TRUE)) ->append_js('module::admin.js') ->append_css('module::admin.css') ->append_css('module::custom.css') ->set('pages', $this->page_m->get_page_tree()) ->set('folders', $this->file_folders_m->get_folders()) ->build('admin/index'); } 
+4
source share
1 answer

@Youhan is right. You can load a view from another view. But the parameters that he gives are erroneous. If you set the third parameter to true , the function will return the view as a string.

So, you just need to add this line to your admin_product_details view:

 $this->load->view('fragments/wysiwyg'); 

EDIT

Why don't you just use your template?

 public function ajax_product_get_details($product_id = NULL) { if(isset($_POST['id'])) { $product_id = $_POST['id']; } $table = SITE_REF.'_ps_products'; $data['product_details'] = $this->Ps_products_model->table_get_row($table, $product_id); $data['assoc_categories'] = $this->Ps_products_model->product_get_x_categories($product_id); $data['parent_categories'] = $this->Ps_products_model->categories_get_parent_list(); $data['folders'] = $this->file_folders_m->get_folders(); $table_man = SITE_REF.'_ps_products_manufacturers'; $data['manufacturers'] = $this->Ps_products_model->table_get_all($table_man, 'name', 'asc'); $this->template ->title($this->module_details['name']) ->append_metadata($this->load->view('fragments/wysiwyg', array(), TRUE)) ->build('admin/ajax/admin_product_details', $data); } 
+1
source

Source: https://habr.com/ru/post/1483514/


All Articles