l(t('Edit'), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination())),
「編集」という単語を代わりに画像に置き換えたいのですが、そこに画像 src を入れるとテキストとして表示されます。私が使用すべき別の機能はありますか?
Drupal をフレームワークとして使用しています。
初心者からのありがとう。
これを行う最善の方法は、l()とtheme_image( ) を組み合わせることです:
print l(theme_image(array('path' => 'edit_button.png', 'attributes' => array('title' => t('Edit')))), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination(), 'html' => TRUE));
イメージのパスの前にdrupal_get_path()を使用する必要もあります。このようにして、Drupal コーディング標準に完全に適用し、生活を楽にします。
そのボタンには、たとえば、独自のクラス、action_button
または などの ID が必要edit_button
です。以下に示すように、CSS を使用してテキストを非表示にし、その場所に背景画像を使用します。
.action_button, #edit_button {
/* Hide Text */
text-indent: -9999px;
display: block;
background: url('edit_button.png') no-repeat;
/* Set width and height equal to the size of your image */
width: 20px;
height: 20px;
}
編集1:
以下でコードを変更し、上記の CSS を使用します。
l(t('Edit'), 'node/'.$node->nid.'/webform/components/'.$cid, array('attributes' => array('id' => array('edit_button')), 'query' => drupal_get_destination()));
編集 2 [最終]:
メソッドにhtml
asTRUE
を渡すと、リンクとして表示するテキストだけでなく、タグとして使用できるようになります。array parameter
l()
first parameter
img
l('<img src="edit_button.png" alt="Edit" />', 'node/'.$node->nid.'/webform/components/'.$cid, array('query' => drupal_get_destination(), 'html' => 'TRUE'));