• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 3.1.0 - parse folder

#1
Hi forum,

Actually In my Index controller i have $data with among others :
PHP Code:
'sectionFiles'            => ['rightmenu''home_slider''infobox''seoscore''home_offers''video_feature''services_blocks''counters''home_expertiseintro'],
...
$this->load->view('site/template'$data); 

In views/site/sections I cut each page into several files and in the file template.php I have :

PHP Code:
<?php
    $this
->load->view('site/global/head');
    
$this->load->view('site/global/header');
// ===== DYNAMIC TEMPLATE =====

    
if (isset($sectionFiles) && !empty($sectionFiles)) {
        foreach (
$sectionFiles as $file) {
            
$this->load->view('site/sections/'.$file);
        };
    };

// ===== END - DYNAMIC TEMPLATE =====
    
$this->load->view('site/sections/newsletter');
    
$this->load->view('site/global/footer');
?>

I would add some php code to :
1. parse site/sections/
2. make an array
3. compare with $data
4. display only files who are featured in $data

Could oyu please help me ? Huh

Regards and nice da y ! Huh
Reply

#2
Why do you need to compare it? It will only loop through whatever you put in it.
So delete some values from sectionFiles and it will not load them.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.