decisions加入代码后产生错误
如之前问题,想在投票成绩下加入图片。 测试加了代码。但不成功,效果变成每一段成绩显示图片。 function theme_decisions_bar($title, $vote, $total_votes, $max_votes) { $output = '<div class="text" >'. $title .'</div>'; $output .= '<div class="bar"><div style="width: '. round(100 * $vote / $max_votes, 0) .'%;" class="foreground"></div></div>'; $output .= '<div class="percent">'. round(100 * $vote / $total_votes, 0) .'% ('. format_plural($vote, '1 vote', '@count votes') .')</div>'; $output .= '<div id="bdgimg" style="background:#ff0000; display:block; height:200px; width:500px;">'; $output .= '</div>'; return $output; } 如果加入<?php ?>,代码不能运行,是module的关系,写法不同? function theme_decisions_bar($title, $vote, $total_votes, $max_votes) { $output = '<div class="text" >'. $title .'</div>'; $output .= '<div class="bar"><div style="width: '. round(100 * $vote / $max_votes, 0) .'%;" class="foreground"></div></div>'; $output .= '<div class="percent">'. round(100 * $vote / $total_votes, 0) .'% ('. format_plural($vote, '1 vote', '@count votes') .')</div>'; return $output; } <?php <div id="bdgimg" style="background:#eee; display:block; height:200px; width:500px;"> ?> 是不是一定要加多一个function,但不知道function是用什么,还有需要什么变量,只需要显示图片罢了。 function xxx($xxx) { $output .= '<div id="bdgimg" style="background:#ff0000; display:block; height:200px; width:500px;">'; $output .= '</div>'; return $output; } |
|
dolbyaterLv 7
|
2 个回答
这个是php基础。
存在很明显的语法错误。。。。。
这是很肯定错的。你就当模块就是php,没什么区别的,php中,这个写法是不能运行的
第一种写法没语法问题,但我不晓得你这个模块的写法。你可以看看生成的html判断它是怎么回事。
不过我感觉你这个改法不太好。我建议你还是彻底点的。
要么在这个模块基础上进行多加一个图片字段上去。
要么就直接参考这个模块,重新写一个模块实现投票。
孤魂Lv 10
谢谢指导。
dolbyaterLv 7