视图控制器中的 href 问题 [英] href issue in view-controler

查看:36
本文介绍了视图控制器中的 href 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含调用视图的特定链接的页面.在控制器中执行相应的函数后显示视图页面 html 包含以下行

I have a page with a specific link that is to call a view. The view is displayed after the coresponding function in the controller is executed The page html contains the following line

<a href="xxxxxxx">Click to view</a>

控制器包含

public function get_comments()
    {
        if(!file_exists('application/views/blog/list_comment_view.php'))
        {
            show_404();
        }
        else
        {
            $row_nums=$this->blog->get_row_nums();
            $config['base_url']=base_url().'index.php/blog/list_comment_view';
            $config['total_rows']=$row_nums;            
            $config['per_page']=5;
            $config['num_links']=2;
            $config['full_tag_open']='<p>';
            $config['full_tag_close']='<p>';
            $config['first_link']='First';
            $config['last_link']='Last';
            $this->pagination->initialize($config);
            $data['comments']=$this->blog->get_comments($config['per_page'],$this->uri->segment(3));
            $this->load->library('table');
            $this->table->set_heading('No','Title','Created','Modified','Action');
            $this->load->view('blog/list_comment_view', $data);
        }
    }

list_view.php 是

The list_view.php is

<body>
<div>Welcome ,
<?php
    $array=$this->session->userdata('db_result');
    echo $array[0]['name'];
?></div>
<?php    

    $this->table->generate($comments);
    $this->pagination->create_links();
?>
</body>

我想知道我应该用什么来替换 XXXXXX,因为我直接将get_comments"放在那里,但它无法显示 list_view.php.由于 list_view.php 中的 $comments 值为零,因此没有显示任何内容.

I would like to know what I should replace XXXXXX with because I directly put "get_comments" in there but it fails to display the list_view.php. There is nothing shown since the value $comments in the list_view.php is zero sized.

对不起大家,它有效,实际上,很好.我忘记回显" generate($comments);:-D 感谢大家的阅读和关心..

推荐答案

如果它没有被加载,那么在你的控制器中加载它(即加载视图)

If it's not loaded then load it in your controller (that is loading the view) by

$this->load->helper('url');

如果已加载(自动加载),则跳过此行

If loaded (autoload), skip this line then

<a href="<?php echo site_url("classname/get_comments");?>">Click to view</a>

classname 是包含函数 get_comments 的类的名称.有关更多信息,请阅读 http://codeigniter.com/user_guide/helpers/url_helper.html 上的文档

classname is the name of your class that contains the function get_comments. For more information please read the documentation at http://codeigniter.com/user_guide/helpers/url_helper.html

这篇关于视图控制器中的 href 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆