如何在cakephp中的一个函数中调用两个不同的.ctp文件?

时间:2013-03-18 10:16:03

标签: cakephp

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

2 个答案:

答案 0 :(得分:1)

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

$this->render('your_view_file');

see Rendering a specific view

答案 1 :(得分: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);