如何使用代码点火器在控制器的锚点内显示通知


How do I display a notification within an anchor in my controller using codeigniter

我正在尝试从锚点内显示通知

在我的控制器中,我有这个数组,它被保存到

$data['table_data'];

然后通过调用 $data_table 显示在我的视图中

$this->table->add_row($cellCl,$cellT,$cellE,$cellA,$cellTR,  
anchor('notifications/print/'.$reg->id,'.',array('class'=>'img1')).'   
'.anchor('notifications/write/'.$reg->id,'.',array('class'=>'img2')).' 
'.anchor('notifications/read/'.$reg->id,'.',array('class'=>'notification'))  
);

我想显示类似于锚点内显示通知图像(而不是显示通知图像)的代码段中的内容。

a.fa-globe {
  position: relative;
  font-size: 2em;
  color: grey;
  cursor: pointer;
}
span.fa-comment {
  position: absolute;
  font-size: 0.6em;
  top: -4px;
  color: red;
  right: -4px;
}
span.num {
  position: absolute;
  font-size: 0.3em;
  top: 1px;
  color: #fff;
  right: 2px;
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" />
<a class="fa fa-globe">
  <span class="fa fa-comment"></span>
  <span class="num">2</span>
</a>

anchor函数的第二个参数通常是显示在<a>元素之间的文本。

EG

echo anchor('url', 'Text'); // <a href="url">Text</a>

但这不仅限于文本内容。你也可以输入 HTML。

EG

echo anchor('url', '<span style="color: red">Test</span>');
// <a href="url"><span style="color: red">Test</span></a>

因此,您可以将<span class="fa fa-comment"></span><span class="num">2</span>添加到anchor的第二个参数中,以使其呈现 HTML。