0

我正在尝试让 Joomla topbanner 显示 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;

我在后端使用分隔符对其进行了编辑,但它仅读取第二张图像和链接。

请问有什么帮助吗?

4

1 回答 1

0

问题在于这一行:

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

您不是在 cocatenating $html,而是在重新分配它。所有旧信息都丢失了。只需这样做:

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