简体   繁体   English

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

[英]codeigniter view are not loading in constructor with parameter

I am trying to load a view from constructor with parameter $data. 我正在尝试使用参数$ 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. 在上面的代码中,我正在检查登录用户是否具有访问权限,然后通过if case块中的错误进行其他操作。

In IF case it loads the error template. 如果是这种情况,它将加载错误模板。

Please somebody help me to fix the above issue ASAP! 请有人帮助我尽快解决以上问题!

Call parent::__construct() , not parent::Controller() . 调用parent::__construct() ,而不是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: 在明确使用CodeIgniter 1.7.1并显示视图本身之后,这就是您的问题:

Your view tries to echo $error instead of $sn_error . 您的视图试图回显$error而不是$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. 如果您不将$data传递给视图,则不会设置$sn_error (已检查)并且不会发生该错误-这就是在这种情况下加载视图的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM