2014-05-22 116 views
0

我在笨框架新的,我只是想转换这个PHP代码到笨版本笨“锚”标签

echo '<td><a rel="facebox" href=useredit.php?emp_id='. $row['emp_id'] .'><button type="button" class="btn btn-primary">Edit</button></td></a>' ; 

我见过这样

echo '<td>' . anchor('user/edit_user/'. $i->id, 'edit'). '</td>'; 

的例子,但我困惑于我如何添加rel和类标记。还有按钮
顺便说一句,我使用的引导和'facebox'是一个jQuery对话框,所以当我点击按钮时,对话框将出现与该用户的信息。

我希望有人可以帮助我。非常感谢你

回答

0
echo anchor("useredit.php?emp_id=". $row['emp_id']", "<button type='button' class='btn btn-primary'>Edit</button>", "rel='Facebox'"); 

你也有不正确结束标记和TD

0

从CodeIgniter用户指南:

- 锚定(URI段,文本,属性)

-The第三个参数可以包含您想要添加到链接的属性列表。属性可以是简单的字符串或关联数组。

所以,你可以这样做:

$args = array("rel"=>"content","target"=>"_blank", "class"=>"your_class");

链接:http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

0

为了使用CI中的锚功能,您必须首先要么通过将其添加到自动加载器列表加载URL帮手或者在调用锚函数之前将$this->load->helper('url');放入控制器中。

你会再使用echo '<td>'.anchor('useredit.php?emp_id='.$row['emp_id'], '<button type="button" class="btn btn-primary">Edit</button>', 'rel="Facebox"').'</td>';

锚函数接受3个参数。第一个('useredit.php?emp_id='.$row['emp_id'])是您通常放置在href属性中的相对链接。第二个是您希望出现在锚点标记('<button type="button" class="btn btn-primary">Edit</button>')之间的html,第三个包含您要应用于锚点的其他html属性,例如id,class或target属性。在你的情况下,你只需要添加'rel="Facebox"'

参考在http://defunkt.io/facebox/该手册Facebox表明你会加载Facebox jQuery和CSS和JS,然后使用JavaScript文件下面来Facebox附加到链接:

jQuery(document).ready(function($) { 
    $('a[rel*=facebox]').facebox() 
}) 
0

这里有从URL Helper : CodeIgniter User Guide

采取了一些示例本:

echo anchor('news/local/123', 'My News', 'title="News title"'); 

将产生:

<a href="http://example.com/index.php/news/local/123" title="News title">My News</a> 

而且这样的:

echo anchor('news/local/123', 'My News', array('title' => 'The best news!')); 

将产生:

<a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a> 

所以,你的情况,你可以这样做:

echo '<td>' . anchor('useredit.php?emp_id=' . $row['emp_id'], '<button type="button" class="btn btn-primary">Edit</button>', 'rel="whatever_you_want_here"') . '</td>'; 
-1

不要乱用在这个阶段复杂的功能,因为你是新的。

只需将您的代码像下图所示。

echo '<td><a rel="facebox" href=user_controller/user_edit/'. $row['emp_id'] .'><button type="button" class="btn btn-primary">Edit</button></td></a>' ;

Class user_controller extends CI_Controller{ 
     function user_edit($userid){ 
      echo $userid; 
      // you can find the user Id in this way and continue your editing 
     } 
} 
0

试试这个...

<td> 
<?php $style='<button type="button" class="btn btn-primary">Edit</button>'; echo anchor('useredit.php?emp_id='.$row['emp_id'],$style,'rel="facebox"');?> 
</td>