doushan5245 2012-07-03 06:44
浏览 46
已采纳

codeigniter视图未在带参数的构造函数中加载

I am trying to load a view from constructor with parameter $data. Earlier it was working fine and now suddenly it stopped working. Below is the code:

permissionerror View

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="6" align="left" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-left.gif" width="5" height="34" /></td>
                <td height="34" align="left" valign="middle" background="<?php echo base_url();?>images/bg/topbg.gif" class="heading">Access Forbidden</td>
                <td width="6" align="right" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-right.gif" width="5" height="34" /></td>
              </tr>
              <tr>
                <td align="left" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-left.gif">&nbsp;</td>
                <td height="165" valign="top"  bgcolor="#FFFFFF" class="leftredheading"><div style="margin:30px auto;padding-left:15px"><? if(isset($sn_error)) echo $sn_error;?></div></td>
                <td align="right" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-right.gif">&nbsp;</td>
              </tr>
              <tr>
                <td align="left" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-left-corner.gif" width="5" height="5" /></td>
                <td valign="top" background="<?php echo base_url();?>images/bg/bottom-bg.gif"></td>
                <td align="right" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-right-corner.gif" width="5" height="5" /></td>
              </tr>
            </table>

Template code:

<?php $this->load->view('includes/login/header'); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#e7e7de">
  <tr>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="100%">&nbsp;</td>
    <td width="161"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"> <?php $this->load->view('includes/login/top_right'); ?> </td>
      </tr>
      <tr>
        <td height="50" background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif">&nbsp;</td>
      </tr>
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="166" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top"><img src="<?php echo base_url();?>images/bg/needhelp-top.gif" width="166" height="7" /></td>
          </tr>
          <tr>
            <td align="center" valign="top" bgcolor="#F8F7EC"> <?php $this->load->view('includes/login/bottom_right'); ?>
                <br /></td>
          </tr>
          <tr>
            <td align="left" valign="top" bgcolor="#F8F7EC"><img src="<?php echo base_url();?>images/bg/needhelp-bottom.gif" width="166" height="7" /></td>
          </tr>
        </table>
          <br /></td>
      </tr>
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="191" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="6" align="left" valign="top"><img src="<?php echo base_url();?>images/bg/left-bttom.gif" width="6" height="6" /></td>
            <td width="100%" background="<?php echo base_url();?>images/bg/leftbottom.gif"></td>
            <td height="6" align="right" valign="top"><img src="<?php echo base_url();?>images/bg/right-bttom.gif" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
    </table>
         <br /></td><td>&nbsp;</td>
    <td valign="top"  <? if($main_content != 'dashboard' || $main_content == 'publisher_dashboard') { ?> colspan="3" <? } ?>><?php $this->load->view($main_content); ?></td>
    <td>&nbsp;</td>
    <? if($main_content == 'dashboard' || $main_content == 'publisher_dashboard') { ?>
    <td align="right" valign="top"> <?php $this->load->view('includes/login/left'); ?>
    </td>
    <? } ?>
    <td>&nbsp;</td>
  </tr>
</table>
<?php $this->load->view('includes/login/footer'); ?>

Here in the above code i am checking whether logged in user is having permission for access then do else part otherwise through the error from if case block.

In IF case it loads the error template.

Please somebody help me to fix the above issue ASAP!

  • 写回答

1条回答 默认 最新

  • dongqiao8421 2012-07-03 07:23
    关注

    Call parent::__construct(), not parent::Controller().

    Edit:

    After it was made clear that CodeIgniter 1.7.1 is used and after the view itself was shown, this is your issue:

    Your view tries to echo $error instead of $sn_error. If you don't pass $data to the view, then $sn_error (which is checked for) isn't set and that error doesn't occur - that's why the view gets loaded in that case.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错