0

我在 Joomla 中有一个问题,我有一个从菜单创建选择下拉列表的模块。

如果我在页面上只有 1 个下拉菜单,则效果很好 - 如果我通过创建从另一个菜单(即 dropdown1 和 dropdown2)拉出的模块的另一个实例来创建 2 个下拉菜单,则页面崩溃。

我想知道这是否与我的模块 default.php tmpl 文件中的以下代码有关:

<?php
// No direct access.
defined('_JEXEC') or die;
?>
<form name="SelMenFrm">
<?php if($params->get('showLabel') == 1) echo $params->get('selectLabel')."&nbsp;"; ?>
<select name="SelMenSel" class="<?php echo $class_sfx;?>" onchange="javascript:location.href=document.SelMenFrm.SelMenSel.options[document.SelMenFrm.SelMenSel.selectedIndex].value;">
<option><?php echo $params->get('topText');?></option>
<?php
foreach ($list as $i => &$item) :
    // Determine if item shoud be set as selected
    $selected = "";
    if (($item->home == 0) && ($item->id == $active_id)) $selected = "selected=\"selected\"";
    // Set indent
    if ($item->level == 1) $indent = "";
    if ($item->level == 2) $indent = "&nbsp;-&nbsp;";
    if ($item->level == 3) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 4) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 5) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 6) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    echo "<option ".$selected."value=\"".$item->flink."\">".$indent.$item->title."</option>";
endforeach;
?>
</select></form>

任何想法/帮助将不胜感激;)

谢谢

4

2 回答 2

0

if you're loading the modules with this code:

<select name="SelMenSel" class="<?php echo $class_sfx;?>" onchange="javascript:location.href=document.SelMenFrm.SelMenSel.options[document.SelMenFrm.SelMenSel.selectedIndex].value;"

then they can't work, as they would have the same id and onchange is relying on the id to identify the select: document.SelMenFrm.SelMenSel

于 2013-01-25T20:58:36.303 回答
0
$indent = str_repeat("&nbsp;",($item->level>=1?($item->level-1):0));

那个怎么样?

于 2013-01-25T12:50:23.780 回答