简体   繁体   English

如何使按钮重定向到Codeigniter中的外部链接?

[英]How to make button redirecting to external link in codeigniter?

I'm newbie here. 我是新手。 I am very need help from you to solve this problem, please. 我非常需要您的帮助来解决这个问题。

I want to link the button name 'lihat rincian' and every row of tables to redirect to external link like http://website.com/ 我想链接按钮名称“ lihat rincian”和表的每一行以重定向到外部链接,例如http://website.com/

My view of datatables Image 我对数据表的看法

The view is datatables, and that button is on my controller. 该视图是数据表,该按钮在我的控制器上。 The function for link to other page before is 'detail' and for list for datatables is 'ajax_list2'. 之前链接到其他页面的功能是“详细信息”,而数据表列表的功能是“ ajax_list2”。 For information my database name is 'crud' and tables is 'edulib' 有关信息,我的数据库名称为“ crud”,表名为“ edulib”

This is my controller. 这是我的控制器。 Controller name : edulibs 控制器名称:edulibs

 /*for load */ public function detail() { $this->session->set_userdata('url',current_url()); $id=$this->uri->segment(3); $data['detail']=$this->edulib_model->get_where('edulib','id',$id); $this->load->helper('url'); $this->load->view('profil',$data); } /* for list */ public function ajax_list2() { $list = $this->edulibs->get_datatables(); $data = array(); $no = $_POST['start']; foreach ($list as $edulibs) { $no++; $row = array(); $row[] = $edulibs->nama; $row[] = $edulibs->pembimbing1; $row[] = $edulibs->pembimbing2; $row[] = $edulibs->subyek; $row[] = $edulibs->judul; $row[] = $edulibs->tanggal; //add html for action $row[] = '<a class="btn btn-sm btn-primary center-block" href="'."detail/".$edulibs->id."".'" title="Tampilkan"><i class="glyphicon glyphicon-eye-open"></i> Lihat Rincian</a>'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->edulibs->count_all(), "recordsFiltered" => $this->edulibs->count_filtered(), "data" => $data, ); //output to json format echo json_encode($output); } 

Thank you very much for your help before. 非常感谢您之前的帮助。 I am very need your help Sorry for bad english. 我非常需要您的帮助对不起,英语不好。

假设通过外部链接,您的意思是在新选项卡中仅可以向链接添加目标属性,对于网站链接,您只需更改href值即可,如下所示:

<a class="btn btn-sm btn-primary center-block" href="http://website.com/" target="_blank" title="Tampilkan"><i class="glyphicon glyphicon-eye-open"></i> Lihat Rincian</a>

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

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