duancong6937 2013-12-23 19:44
浏览 55
已采纳

如何使Joomla Table可排序?

I have added following PHP code in my Joomla webapplication. This will create a table of all users from a User Group.

How Can I make this table sortable?

Is there some Joomla/PHP code or plugin to order this list by Name? Can I add a parameter to sort this by any column?

<?php
$teachers = JAccess::getUsersByGroup(10); //change number in the brackets

echo "<table class=\"table table-striped\">";
echo "<thead>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Street</th>";
echo "<th>Zip</th>";
echo "<th>City</th>";
echo "<th>Phone</th>";
echo "<th>Email</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
foreach($teachers as $user_id) {
    $user = JFactory::getUser($user_id);
    $profile = JUserHelper::getProfile($user->id);
    echo "<tr>";
    echo "<td>".$user->name."</td>";
    echo "<td>".$profile->profile['address1']."</td>";
    echo "<td>".$profile->profile['postal_code']."</td>";
    echo "<td>".$profile->profile['city']."</td>";
    echo "<td>".$profile->profile['phone']."</td>";
    echo "<td>".$user->email."</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
  • 写回答

4条回答 默认 最新

  • dongyuan1870 2013-12-23 19:45
    关注

    I think the easiest way would be to use jquery or use a jquery plugin. You can use DataTables or Tablesorter, they are jquery plugins that would put that feature.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 R语言 拟时序分析降维图如何减少分支
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统