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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题