CakePhp displays a blank view

I have a CakePHP application where all the view works, but two. This is the controller:


And this is the view

Title

Form->create('Card', array( 'url' => array( 'controller' => 'cards', 'action' => 'view' ) )); echo $this->Form->input('codice'); echo $this->Form->end('Cerca');*/ ?>

Checking with the firefox console I got this:

  
  

The “view” view, called by the form has the same problem. Normally if the view is missing Cake return an error, in this case if I delete the index.ctp the result is in any case a blank page. I can’t find what the problem is.

UPDATE 1

My route code:

 'users', 'action' => 'login'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
?>

**UPDATE 2 **

My folder structure

├── Config
│   └── Schema
├── Console
│   ├── Command
│   └── Templates
├── Controller
│   ├── ()
│   ├── Component
│   ├── docs
│   └── output
├── files
├── Lib
├── Locale
│   └── eng
├── Model
│   ├── ()
│   ├── Behavior
│   └── Datasource
├── Plugin
│   ├── AclExtras
│   ├── CakePdf
│   └── DebugKit
├── Test
│   ├── Case
│   └── Fixture
├── tmp
│   ├── cache
│   └── logs
├── Vendor
│   └── tcpdf
├── View
│   ├── ()
│   ├── Cards
│   ├── Clientis
│   ├── Elements
│   ├── Emails
│   ├── Errors
│   ├── Fornitoris
│   ├── Groups
│   ├── Helper
│   ├── Indirizzos
│   ├── Layouts
│   ├── Magsits
│   ├── Movimentis
│   ├── Pagamentos
│   ├── Pages
│   ├── Pdcard
│   ├── Pdf
│   ├── Posts
│   ├── Rdocumentos
│   ├── Rlistinos
│   ├── Scaffolds
│   ├── Storicotransaziones
│   ├── Tdocumentos
│   ├── Titoliviaggios
│   ├── Tmovimentis
│   ├── Users
│   ├── Verificas
│   ├── Voucher
│   └── Widgets
└── webroot
    ├── css
    ├── files
    ├── images
    ├── img
    └── js

UPDATE 3

Card model

 array('foreignKey' => 'pacchetto'), 'Tdocumento' => array('foreignKey' => 'iddocument'));
    public $hasMany = array('Visit' => array('foreignKey' => 'codicecarta'));
    public $primaryKey = 'codicecarta';

    public function afterFind($results, $primary = true) {
        for ($i=0; $i formatodata($results[$i]['Card']['iniziovalidita']);
            $datavisita = $this->formatodata($results[$i]['Card']['dataprenotazione']);
            $results[$i]['Card']['datainizio'] = $datavalidita[0];
            $results[$i]['Card']['orainizio'] = $datavalidita[1];
            $results[$i]['Card']['datavisita'] = $datavisita[0];
            $results[$i]['Card']['oravisita'] = $datavisita[1];
        }
        return $results;
    }

    public $validate = array(
        'nominativo' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'A username is required'
            )
        ),
        'codicecarta'=> array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Inserire il codice'
            )
        )
    );
    private function formatodata($dataora){
        $dataora = explode(' ', $dataora);
        $data = $dataora[0];
        $data = date('d-m-y', strtotime($data));
        $ora = $dataora[1];
        $ora = substr($ora, 0,5);
        return array($data, $ora);
    }
}

UPDATE 4

My View/Layout/default.ctp

    Html->charset(); ?>
    
        :
        
    
    Html->meta('icon');
        echo $this->Html->css('cake.generic');
        echo $this->fetch('meta');
        echo $this->fetch('css');
        echo $this->fetch('script');?>


    
Session->flash(); ?> fetch('content'); ?> element('sql_dump'); ?>

Create Cards
folder in your View folder and add there index.ctp. You may be missing Folder structure which is convention in cakephp.

Remove */
from your code.

I recommand you to create elements like header.ctp, footer.ctp

And use default.ctp for normal usage like this which will include your header , footer and view content.

element('head'); ?>


    Session->flash(); ?>
    fetch('content'); ?>
    element('sql_dump');
          echo $this->Html->script('additional-methods');
    ?>

    
Version :

Make sure you have routs.php like this.

 'Users', 'action' => 'login'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
    Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
    CakePlugin::routes();

/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
    require CAKE . 'Config' . DS . 'routes.php';

An ideal model should look like this :


                  
Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » CakePhp displays a blank view

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录