Welcome Guest, Not a member yet? Register   Sign In
Custom view method
#2

(This post was last modified: 05-06-2020, 11:33 AM by jreklund.)

Here are the complete code for view. You can create your own cView and put in in app/Common.php based on that. Or overwrite the system function.

https://codeigniter.com/user_guide/outgo...derer.html

PHP Code:
if (! function_exists('view'))
{
    
/**
     * Grabs the current RendererInterface-compatible class
     * and tells it to render the specified view. Simply provides
     * a convenience method that can be used in Controllers,
     * libraries, and routed closures.
     *
     * NOTE: Does not provide any escaping of the data, so that must
     * all be handled manually by the developer.
     *
     * @param string $name
     * @param array  $data
     * @param array  $options Unused - reserved for third-party extensions.
     *
     * @return string
     */
    
function view(string $name, array $data = [], array $options = []): string
    
{
        
/**
         * @var CodeIgniter\View\View $renderer
         */
        
$renderer Services::renderer();

        
$saveData config(View::class)->saveData;

        if (
array_key_exists('saveData'$options))
        {
            
$saveData = (bool) $options['saveData'];
            unset(
$options['saveData']);
        }

        return 
$renderer->setData($data'raw')
                        ->
render($name$options$saveData);
    } 
Reply


Messages In This Thread
Custom view method - by imabot - 05-06-2020, 10:38 AM
RE: Custom view method - by jreklund - 05-06-2020, 11:33 AM
RE: Custom view method - by imabot - 05-07-2020, 09:19 PM
RE: Custom view method - by jreklund - 05-08-2020, 09:37 AM
RE: Custom view method - by imabot - 05-09-2020, 10:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB