Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created August 17, 2012 20:20
Show Gist options
  • Save westonwatson/3382289 to your computer and use it in GitHub Desktop.
Save westonwatson/3382289 to your computer and use it in GitHub Desktop.
function display_object($object,$parameters,$action=null){
//this is all a bit redundant, on purpose i guess...
$partial[name] = strtolower( get_class($object) ) . strtolower($action?"_{$action}":"");
//view to render
$partial[filename] = "{$partial_name}.phtml";
//path to check with file_exists
$partial[path] = TRAX_ROOT . "/app/views/includes/" . $partial[filename];
//path within app to use with render_partial
$partial[relative] = "includes/" . $partial[filename];
//check for file
if (file_exists($partial[path])){
//render partial for that object's class
$this->render_partial($partial[relative],$parameters);
}else{
//debug, non-existent view display
echo "<pre>" . print_r($object,true) . "</pre>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment