2014-12-04 3 views
7

안녕하세요 여러분, 내 제품 기반 웹 애플리케이션 중 하나 인 yii2를 배우고 있습니다. 다음 comverting 동안 내가 yii2 HTML 코드 형식으로 & 받고 문제를 기존 코드를 변환하고있다 : 사람이 위를위한 솔루션이있는 경우 나에게 사람을Yii2 HTML 앵커 태그를 yii2 html :: a() 태그에 매핑하는 방법

<a href="grid_options.html"> 
 
<div> 
 
    <i class="fa fa-upload fa-fw"></i> Server Rebooted 
 
    <span class="pull-right text-muted small">4 minutes ago</span> 
 
    </div> 
 
</a>

도움이 ??????

\yii\helpers\Html::a(\yii\helpers\Html::tag('div', 
        \yii\helpers\Html::tag('i', '', ['class' => 'fa fa-upload fa-fw']) . 'Server Rebooted' . 
        \yii\helpers\Html::tag('span', '4 minutes ago', ['class' => 'pull-right text-muted small']) 
       ), \yii\helpers\Url::to('address')); 

이 더 명확 코드가하려면 :

답변

8

알리의 답변 외에도 완전히 쓸만하다.

use yii\helpers\Url; 

    <a href="<?= Url::to('LINK')?>"> 
    <div> 
     <i class="fa fa-upload fa-fw"></i> Server Rebooted 
     <span class="pull-right text-muted small">4 minutes ago</span> 
     </div> 
    </a> 
+0

입니다. .. 감사합니다. @Mihai P :-) – Shaggie

+0

다른 사람이 알 수 있도록 응답을 수락합니다. –

5

다음 코드는 원하는 HTML을 생성, 당신은 경로에 대한 링크를 만들려면

use yii\helpers\Html; 
use yii\helpers\Url; 

Html::a(Html::tag('div', 
     Html::tag('i', '', ['class' => 'fa fa-upload fa-fw']) . 'Server Rebooted' . 
     Html::tag('span', '4 minutes ago', ['class' => 'pull-right text-muted small']) 
    ), Url::to('address')); 

이 있다는 점 유의 하시길 바랍니다을 사용 Url::toRoute(['controller/action'])

+0

나는이 것을 확실하지 않다 html 코드를 지웠다 :). –

+1

그것의 완전한 매핑은 정말 놀랍습니다. Ali ...... 감사합니다. yii2 :-)에서 더 이상 문제가 생기면 다시 도움을 요청하십시오. – Shaggie

+0

질문에 대한 가장 완벽한 대답은 – MrD

1

이도 작동 할 수 :)

<?= Html::a('<div><i class="fa fa-upload fa-fw"></i> Server Rebooted 
    <span class="pull-right text-muted small">4 minutes ago</span> 
    </div>', ['/grid-options'], ['class'=>'your_class']) ?> 
0

당신이 URL 기능 아래 사용하는 것보다 당신의 연결에서 "컨트롤러/액션"및 매개 변수를 사용하려면

Url::toRoute(['product/view', 'id' => 42]);