1

我有 2 个视图文件index.ctpindexMobile.ctp. 我必须为两个 ctp 文件使用一个控制器logincontroller.php和一个函数。

4

2 回答 2

1

如果要渲染特定视图,请在控制器中使用 $this->render

$this->render('your_view_file');

请参阅渲染特定视图

于 2013-03-18T10:20:14.620 回答
0

这是我的例子:

// Changing the "layout" (app/View/Layouts") if you want.
// Change this if you want a different layout for this view.
$this->layout='pdf';

// Folder where is the .ctp View file. 
// This is also optional, if your view is in some other folder.
$this->viewPath = 'Pdf';

// Call the "{$view}.ctp" in "Pdf" folder (app/View/Pdf/{$view}.ctp).
// Use this for choosing the right View.
$this->render($view);
于 2013-03-18T12:00:09.067 回答