dongxie8906 2011-12-12 12:41
浏览 23
已采纳

用于将页面加载到iframe的CI控制器

I want to implement a new module into a site, which is made with CI. I am an absolute newbie with CI and I can not figure out how to create the controller ant the view files. I need the new content to be loaded into an iframe in the current site. So far I have:

controller:

class Module extends Controller {

    function __construct() {
            parent::Controller();

    }

    function index() {
            $this->common->loadView('module/module');
    }
}

view:

<iframe src="/new_module/index.php" width="100%" height="100%" scrolling="NO" frameborder="0" >An iframe capable browser is required to view this web site.</iframe>

route:

$route['module/(:any)'] = "module/$1";

site structure:

resources/
system/
....
new_module/
new_module/index.php
new_module/page1.php
new_module/page2.php

Links should be:

http://mydomain.com/module/page1
http://mydomain.com/module/page2

The link are outside of the iframe and the content should load inside the iframe. So, the iframe src should be changed dynamically.

Obviously, it does not work. Could someone with more experience with CI tell me how it should be done?

Thank you!

  • 写回答

1条回答 默认 最新

  • douti0687 2011-12-12 15:48
    关注

    For the frame to change dynamically, just set the target of the link to the iframe:

    <a href="/pages/page/1" target="targetFrame">Page 1</a>
    <iframe id="targetFrame" src="" width="100%" height="100%" scrolling="NO" frameborder="0" ></iframe>  
    

    As I understand, by default, Codeigniter does not have "modules". That is unless you are using a CMS or somesuch that is built on top of CI in which case you'd need to specify that.

    Otherwise, just use controllers correctly to get what you want.

    class Pages extends Controller{
    
        public function page($id='')
        {
            switch $id{
                case 1:
                    $data['pageData']='foo';
                break;
                ...
            }
            $this->load->view('page_view',$data);
        }
    } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘