CodeIgniter Forums
CI 3.1.0 - parse folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI 3.1.0 - parse folder (/showthread.php?tid=71126)



CI 3.1.0 - parse folder - angecorse - 07-09-2018

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


RE: CI 3.1.0 - parse folder - jreklund - 07-10-2018

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.