0

私は、Joomlaトップバナーに2つの異なるリンクを表示する2つの異なる画像を表示させようとしているので、次のコードを変更しました。

これから:

// get a parameter from the module's configuration
$imgname = $params->get('imgname');
$imgwidth = $params->get('imgwidth', '');
$imgheight = $params->get('imgheight', '90');
$imgtarget = $params->get('imgtarget', '');
$imgpath = JURI::base().'images/stories/';

$html   = "<a href='".$imgtarget."' target='_blank'>";
$html   .= "<img src='".$imgpath.$imgname."' border='0' alt=''       width='".$imgwidth."' height='".$imgheight."'>";
$html   .= "</a>"; 
echo $html;

これに:

// get a parameter from the module's configuration
$imgname = $params->get('imgname');
$imgwidth = $params->get('imgwidth', '');
$imgheight = $params->get('imgheight', '90');
$imgtarget = $params->get('imgtarget', '');
$imgpath = JURI::base().'images/stories/';

//split up image and targets
list($image1,$image2) = explode(',',$imgname);
list($target1,$target2) = explode(',',$imgtarget);

//steps
//divide image into 2 using any image editing tool
//upload to server
//set up images separated by comma in admin
//add second target to admin separated by comma


$html   = "<a href='".$target1."' target='_blank'>";
$html   .= "<img src='".$imgpath.$image1."' border='0' alt='' width='".$imgwidth."'     height='".$imgheight."'>";
$html   .= "</a>"; 
$html   = "<a href='".$target2."' target='_blank'>";
$html   .= "<img src='".$imgpath.$image2."' border='0' alt='' width='".$imgwidth."'    height='".$imgheight."'>";
$html   .= "</a>"; 
echo $html;

バックエンドで区切り文字を使用して編集しましたが、2番目の画像とリンクのみを読み取っています。

何か助けてください?

4

1 に答える 1

0

問題は次の行にあります。

$html   = "<a href='".$target2."' target='_blank'>";

あなたは cocatenating$htmlではなく、再割り当てしています。古い情報はすべて失われます。これを行うだけです:

$html   .= "<a href='".$target2."' target='_blank'>";
于 2012-08-07T13:57:33.293 に答える