[英]Add Class in Anchor for CodeIgniter
First of all, I searched this question here and found some answers but they're not for me. 首先,我在这里搜索了此问题并找到了一些答案,但它们并不适合我。 My code is little bit different.
我的代码有点不同。
This is my anchor structure; 这是我的锚结构;
<?php echo anchor($this->lang->switch_uri('tr')); ?>
I need to use this anchor in this menu structure; 我需要在此菜单结构中使用此锚点;
<li><a class="nav-icon"><i><img src="<?php echo site_url('assets/panel/flags/tr.png'); ?>" width="16" /></i> Türkçe</a></li>
Thanks in advance. 提前致谢。
You can add a class by creating a array in the anchor. 您可以通过在锚点中创建数组来添加类。
example 例
<?= anchor('your link here', 'Name of the anchor', array('title' => 'your anchor title', 'class'=>'your anchor class here')) ?>
Put this where you want a anchor. 将此放置在您想要锚点的位置。
Have a look at the URL helper; 看一下URL帮助器;
https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));
Would produce: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a>
会产生:
<a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a>
So, yours would be; 所以,你会的;
echo '<li>' . anchor('#', '<img src="img_path" /> Text', array('class' => 'myClass')) . '</li>';
I found the answer. 我找到了答案。 It should be like this;
应该是这样
<li><a href="<?php echo site_url($this->lang->switch_uri('tr')); ?>" class="nav-icon"><i><img src="<?php echo site_url('assets/panel/flags/tr.png'); ?>" width="16" /></i> Türkçe</a></li>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.