用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2036|回复: 1
收起左侧

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

[复制链接]
发表于 2012-12-16 13:46:02 | 显示全部楼层 |阅读模式
一个可能非常简单的问题:希望高人指点:
例如:有一个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");?>
感激不尽。





发表于 2012-12-16 15:54:36 | 显示全部楼层
你的目的是输出那些内容吧?
我的做法是使用load->view('view_name', $data, TRUE)来获得显示的内容然后输出到自己定义的template文件中。你可以看下精华贴里面的模板相关内容。

本版积分规则