Missing $css_files

Hi ,
why this error message appears : Undefined variable $css_files
line 7 foreach($css_files as $file): ?>

thanks

can you please add more details? in which file this error occur ? and would you paste your code as well ?

a file like example.php as listed below

!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8" />
 5     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 6 <?php 
 7 foreach($css_files as $file): ?>
 8     <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
 9 <?php endforeach; ?>
10 </head>
11 <body>
12     <div>
13         <a href='<?php echo site_url('AgendaController/contatos_management')?>'>Entidades</a>     
14     </div>
15     <div style='height:20px;'></div> 

can you share its controller?

<?php namespace App\Controllers; class Home extends BaseController { public function index() { return view('agenda'); } }

Hello @fduque ,

I guess you don’t want to load the $css_files into the index right? It doesn’t use Grocery CRUD. The easy way is to just check if the $css_files are empty. The same should happen on $js_files as well.

For example:

<?php 
if (!empty($css_files)) {  // <-- new line here
foreach($css_files as $file): ?>
     <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; 
} // <-- new line here
?>

You should also do the same for the $js_files