LoginSignup
0
0

More than 3 years have passed since last update.

【FuelPHP】Html::anchorを使わずにページ遷移させる

Posted at

問題点 : Html::anchorを使った時

//返り値 <a href="http://www.domain.com/example">Example</a>
echo Html::anchor('example', 'Example');

//返り値 <a href="http://www.otherdomain.com/example">Example</a>
echo Html::anchor('http://www.otherdomain.com/example', 'Example');

公式のドキュメントには上記のように書いていますが、
次のようにaタグの中にspanタグなどを入れたい場合の書き方が解説されていませんでした。

<a href="http://www.domain.com/example>
 <i class=""></i><span>Qiita</span>
</a>

解決策 : Uri::base()を使う

半日頭を悩ませて、Uri::base()を使う結論に至りました。

<a href="<?php echo Uri::base(); ?> example>
 <i class=""></i><span>Qiita</span>
</a>

事前にconfigファイルのbase_urlにベースのurlは書いておかないと使えません。

fuel/app/config/config.php
'base_url'  => 'http://www.domain.com/',

もっといい方法あれば教えていただけると嬉しいです。

ありがとうございました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0