Skip to content

Instantly share code, notes, and snippets.

@StolenThunda
Last active January 24, 2019 18:59
Show Gist options
  • Save StolenThunda/9067b7d42800bf4aa363f02c5ac1b9a4 to your computer and use it in GitHub Desktop.
Save StolenThunda/9067b7d42800bf4aa363f02c5ac1b9a4 to your computer and use it in GitHub Desktop.
function dm_view($view, $path, data=array() ) {
$CI =& get_instance();
$tp = $CI->load->_ci_view_path;
$CI->load->_ci_view_path = $path;
$out = $CI->load->view($view,$data,true);
$CI->load->_ci_view_path = $tp;
return $out;
}
@StolenThunda
Copy link
Author

StolenThunda commented Jan 24, 2019

-- Views in template tags

Whilst Ellis Labs might not like the use of front end views, as a PHP dev it’s one of the best things about EE2. With most of my projects the end client has nothing to do with the templates so a module tag that outputs based on views is no issue.

However, there is some housekeeping to do if you’re going to switch to views, as you need to change the view path back in case something else is using it. A helper function similar to this is useful:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment