我,试图让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;
我在后端用分隔符编辑了它,但它只是读取第二张图像和链接。
请帮忙吗?
答案 0 :(得分:0)
问题在于这一行:
$html = "<a href='".$target2."' target='_blank'>";
你不是要$html
,你要重新分配它。所有旧信息都丢失了。只需这样做:
$html .= "<a href='".$target2."' target='_blank'>";