Access variable in a view
4 years ago
4 years ago
#1
Hello, I'm passing a block of text which is in the content_module over to the layout_dashboard which has the header and footer. I can't seem to access the meta_title inside the content module. I am echoing out the $meta_title inside the dashboard.php file. $data['meta_title'] = 'Dashboard'; $data['content_module'] = 'dashboard'; $this->view('layout-dashboard', $data);
4 years ago
#2
Can someone please help me out with this. Thanks!
4 years ago
#3
Hello, What is the module name you are trying to pass the data to and where is the view file located? Put this in json($data, true); right before your $this->view('layout-dashboard', $data); This will show you what data you are passing to the view file. Access the data in the view file example. Post your code from the view file Is your layout-dashboard in the content_module Dan
4 years ago
#4
In the dashboard views module is dashboard.php & layout-dashboard.php dashboard.php is unable to access the meta_title
4 years ago
#5
$data['view_module'] = 'members'; $data['view_file'] = 'check_your_email'; $this->template($this->template_to_use, $data);
4 years ago
#6
Hi Andrew, Dan is on the right track here about using templates to insert parts of your page. I think you are confusing the matter by trying to pass more than one view. Please refer to the documentation on views >> https://trongate.io/docs/information/passing-data-into-view-files and templates https://trongate.io/docs/information/passing-information-into-templates
4 years ago
#7
Thank you!! I created a template with partials and it works great! :D
4 years ago
#8
Hi Andrew, could you please close this thread off and award to Dan who suggested using templates.
4 years ago
#9
Would be nice if there was a title for the star icon. I didn't know what it does.
4 years ago
#10
I agree with you Maybe when the site gets updated. New site coming soon Dan