如何使mod_topbanner显示 2 张图像到 2 个不同的链接


how to make mod_topbanner show 2 images to 2 different links

我试图让 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;

我用分隔符在后端编辑了它,但它只读取第二个图像和链接。

请帮忙吗?

问题出在以下行上:

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

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

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