+ Reply to Thread
Results 1 to 2 of 2

Thread: Read / Scan directory using MVC

  1. #1
    RiquinHo is offline Junior Member
    Join Date
    Mar 2010
    Location
    Niterói - RJ
    Posts
    4

    Cool Read / Scan directory using MVC

    Hi, I'm having some doubts about how to read a directory in my controller and display the result in my view. By now, I have the following code to read AND display result in my controller:

    ================================================== ==

    $dir = new DirectoryIterator(APPLICATION_PATH.'modules/');
    foreach ($dir as $fileinfo) {
    if (!$fileinfo->isDot() && $fileinfo->isDir()) {
    echo $fileinfo->getFilename().'<br />';
    }
    }

    ================================================== ==

    How can I set this echo to be part of the view and not the controller?
    Thanks in advance, Henrique Mattos

  2. #2
    RiquinHo is offline Junior Member
    Join Date
    Mar 2010
    Location
    Niterói - RJ
    Posts
    4

    Wink The Solution:

    in the controller:

    Code:
    $dir = new DirectoryIterator(APPLICATION_PATH.'modules/');
    foreach ($dir as $fileinfo) {
       if (!$fileinfo->isDot() && $fileinfo->isDir()) {
          $dirs[].= $fileinfo->getFilename();
          $this->view->module_name = $dirs;
       }
    }
    and in the view:

    Code:
    <?php foreach($this->module_name as $module_name) : ?>
       <?php echo $module_name; ?><br />
    <?php endforeach; ?>

+ Reply to Thread

Similar Threads

  1. Zend_Translate "scan" not working
    By nasht00 in forum Internationalization (i18n) & Localization (l10n)
    Replies: 0
    Last Post: 05-13-2010, 09:07 PM
  2. Release Read Lock
    By jobspert in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 03-27-2010, 08:36 AM
  3. How to read parameters from URL in ZF?
    By keenlio in forum Model-View-Controller (MVC)
    Replies: 7
    Last Post: 10-08-2008, 06:02 PM
  4. directory structure vs root directory
    By TheZend in forum Installation & Configuration
    Replies: 1
    Last Post: 07-11-2008, 05:08 PM
  5. Read Entries
    By tigerlily in forum Web & Web Services
    Replies: 1
    Last Post: 07-07-2008, 10:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts