Welcome Guest, Not a member yet? Register   Sign In
How to use view to load a CSS file
#5

(This post was last modified: 05-21-2018, 09:05 AM by John_Betong.)

(05-21-2018, 05:46 AM)kilishan Wrote: Your error states Argument 3 passed to view() must be of the type array, boolean given. A look at the code for the view() function shows it's looking for an $options array, which really only has one valid value at the moment: 'saveData'. Where in the manual is it stating to pass a true/false as the third parameter? We need to update that if you can show us where.

From the Online Manual:

/*
Maybe incorrect Boolean $saveData - should be array['save'=true]; ?
*/
https://bcit-ci.github.io/CodeIgniter4/g...t=savedata
$data = [
        'title'   => 'My title',
        'heading' => 'My Heading',
        'message' => 'My Message'
];
echo view('blogview', $data, ['saveData' => true]);
Additionally, if you would like the default functionality of the view method to be that it does save the data between calls, you can set $saveData to true in application/Config/Views.php.


/*
Uses Boolean
*/
https://bcit-ci.github.io/CodeIgniter4/g...t=savedata
CodeIgniter\View\Parser
render($view[, $options[, $saveData=false]]])


/*
Uses Boolean
*/
https://bcit-ci.github.io/CodeIgniter4/g...t=savedata
CodeIgniter\View\View
  render($view[, $options[, $saveData=false]]])
      Parameters:
          $view (string) – File name of the view source
          $options (array) – Array of options, as key/value pairs
          $saveData (boolean) – If true, will save data for use with any other calls, if false, will clean the data after rendering the view.


/*
Uses Boolean
*/
https://bcit-ci.github.io/CodeIgniter4/g...t=savedata
renderString($view[, $options[, $saveData=false]]])
  Parameters:
      $view (string) – Contents of the view to render, for instance content retrieved from a database
      $options (array) – Array of options, as key/value pairs
      $saveData (boolean) – If true, will save data for use with any other calls, if false, will clean the data after rendering the view.


//================================================
I managed to solve the problem of using View to load a CSS file:

CodeIgniter\View\View::render ==> Line: 170

PHP Code:
# echo  __method__ .' ==> Line: ' .__line__ ;die;

# IF AND ONLY IF APPEND .php WHEN NO FILE EXTENSION EXISTS
 
 ifstrpos$view'.' ) ):
 
   # ASSUME FILE OK AND DO NOT APPEND .php
 
     $this->renderVars['view'] = $view;
 
 else:    
 
  # ORIGINAL SCRIPT 
 
    $this->renderVars['view'] = str_replace('.php'''$view) . '.php';
 
 endif
Reply


Messages In This Thread
RE: How to use view to load a CSS file - by John_Betong - 05-21-2018, 08:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB