문제

Symfony 1.4를 사용하고 있으며 다음을 달성 할 수 있는지 궁금합니다.

<a href="#"><span>Text</span></a>

... Symfony의 link_to 도우미 사용?

물론이 작업을 수행 할 수 있습니다.

<a href="<?php echo url_for('#') ?>"><span>Text</span></a> 

그러나 특히 i18N을 위의 내용과 결합하는 것이 더 간단한 방법이 있는지 궁금합니다.

<a href="<?php echo url_for('#') ?>"><span><?php echo __('Text') ?></span></a> 

... 기본적으로 태그 수프.

감사.

도움이 되었습니까?

해결책

두 가지 방법으로 할 수 있습니다 ...

옵션 1

<?php echo link_to("<span>".__('Text')."</span>", $url); ?>

옵션 2

<?php echo content_tag('a',  "<span>".__('Text')."</span>", array('href' => url_for($url))); ?>

다른 팁

또한 :

<?php echo link_to(content_tag('span', __'Text', array('class' => 'span-class')), '@route', array('class' => 'link-class'));

속성을 추가했습니다 class 두 개의 HTML 태그 각각에 대해 옵션으로 옵션을 확장 해야하는 경우 옵션으로.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top