0
   l(t('Edit'), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination())),

「編集」という単語を代わりに画像に置き換えたいのですが、そこに画像 src を入れるとテキストとして表示されます。私が使用すべき別の機能はありますか?

Drupal をフレームワークとして使用しています。

初心者からのありがとう。

4

3 に答える 3

2

これを行う最善の方法は、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 コーディング標準に完全に適用し、生活を楽にします。

于 2012-05-20T18:21:59.490 に答える
1

そのボタンには、たとえば、独自のクラス、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 [最終]:

メソッドにhtmlasTRUEを渡すと、リンクとして表示するテキストだけでなく、タグとして使用できるようになります。array parameterl()first parameterimg

l('<img src="edit_button.png" alt="Edit" />', 'node/'.$node->nid.'/webform/components/'.$cid, array('query' => drupal_get_destination(), 'html' => 'TRUE'));
于 2012-05-20T17:31:01.637 に答える