improved view.php (one function for front & backend)