doudu7626 2014-08-22 16:09
浏览 25

页面感知能够分配类

So I have a list of users within a list of taxonomies in a sidebar. I need to be able to have the list of users stay open (they are closed by default and open on click) if the current page is a user page. So for a user within taxonomy A, on that users page the list of users for taxonomy A would be open by default. Basically, I need to create a context awareness similar to how WordPress does with menus.

Here is the loop that creates the list:

<div class="sidebar sidebar-people">
  <div class="menu-people-menu-container">
    <?php $disciplines = get_terms('disciplines');
  echo "<ul id='menu-people-menu' class='menu'>";
  foreach($disciplines as $discipline) {
    $params = array('limit' => -1,'where' => 'user_discipline.term_id = ' . (int) $discipline->term_id. ''); 
    $mypod = pods( 'user', $params );
    if ( 0 < $mypod->total() ) { 
    echo '<li><a href="#">' . $discipline->name . '</a>';

      $users = get_users('meta_value='. $discipline->term_id .'');
      if(count($users)>0) { 
        echo '<ul class="sub-menu postid-'. get_the_id() .'">';
        foreach( $users as $user ){
          echo '<li><a href="'. home_url(mb_strtolower('/culture/our-people/'. $user->user_firstname .'-'. $user->user_lastname) ). '">' . $user->user_firstname .' '. $user->user_lastname . '</a></li>';
        }
      } else {
        echo '<li><a href="#">No results found</a></li>';
      }

        echo '</ul></a></li>';
    }
  }

  echo "</ul>";

  ?>  

  </div> 
</div>

And here's the JS that opens and closes it:

//Sidebar Menu SLide Toggles
$("#menu-people-menu").on("click", "> li > a", function (e) {
    e.preventDefault();
    $("#menu-people-menu").find(".sub-menu").hide();
    $(this).closest("li").find(".sub-menu").first().fadeToggle("slow");
});

How do I go about keeping taxonomy a open when on the user 1 page dynamically?

Taxonomy A -user 1 -user 2 -user 3 Taxonomy B -user 4 -user 5 -user 6 Taxonomy C -user 7 -user 8 -user 9

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!