彳亍 发表于 2012-12-16 13:46:02

CI能否在视图中直接调用controller的函数?

一个可能非常简单的问题:希望高人指点:
例如:有一个view的页面是:
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <link href="<?= base_url()?>css/style.css" rel="stylesheet">
<title>供求信息网</title>
        <style type="text/css">
                <!--
                body {
                        background-image: url(<?= base_url()?>Images/bg.gif);
                }
                -->
        </style>
</head>
<body>
        <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr valign="top">
          <td colspan="2"><?php include("top.php");?></td>
          </tr>
          <tr>
          <td width="217" valign="top" background="Images/line2.gif"><?php include("left.php");?></td>
          <td width="586" valign="top" bgcolor="#FEFEF6"><?php include("main.php");?></td>
          </tr>
          <tr>
          <td colspan="2"><?php include("bottom.php");?></td>
          </tr>
        </table>
</body>
</html>
这个我想用controller下面index.php的left、main,bottom方法,如何调用实现替换<?php include("left.php");?>,<?php include("main.php");?>
<?php include("bottom.php");?>
感激不尽。





seedo 发表于 2012-12-16 15:54:36

你的目的是输出那些内容吧?
我的做法是使用load->view('view_name', $data, TRUE)来获得显示的内容然后输出到自己定义的template文件中。你可以看下精华贴里面的模板相关内容。
页: [1]
查看完整版本: CI能否在视图中直接调用controller的函数?