完成个人中心 导航标签

      1. 个人中心—视图函数带标签页面参数tag
        @app.route('/usercenter/<user_id>/<tag>')
        def usercenter(user_id, tag):
           if tag == ‘1':
               return render_template('usercenter1.html', **context)

      2. 个人中心—导航标签链接增加tag参数
        <li role=“presentation”><a href=“{{ url_for(‘usercenter’,user_id = user.id,tag = ‘1’) }}">全部问答</a></li>
      3. 个人中心—有链接到个人中心页面的url增加tag参数
        u <a href="{{ url_for('usercenter',user_id = session.get('userid'), tag=1) }}">{{ session.get('user') }}</a>
    1. {% extends 'base.html' %}
      {% block title %}
      个人中心
      {% endblock %}

      {% block link %}

      {% endblock %}

      {% block box %}
      <div class="container">
      <div class="row clearfix">
      <div class="col-md-2 column">
      </div>
      <div class="col-md-8 column">
      <ul class="nav nav-tabs">
      <li role="presentation"><a href="{{ url_for('comment',user_id=user2.id,num='1') }}">全部问题</a></li>
      <li role="presentation"><a href="{{ url_for('comment',user_id=user2.id,num='2') }}">全部评论</a></li>
      <li role="presentation"><a href="{{ url_for('comment',user_id=user2.id,num='3') }}">个人信息</a></li>
      </ul>
      {% block subComment %}{% endblock %}
      </div>
      <div class="col-md-2 column">
      </div>
      </div>
      </div>
      {% endblock %}

      {% block script %}

      {% endblock %}
    2. {% extends 'comment.html' %}
      {% block subComment %}
      <ul class="list-group" style="">
      <h1>全部问题</h1>
      {% for foo in questions %}
      <li class="list-group-item" style="width: 800px">
      <a class="wrap-img" href="#" target="_blank">
      <img src="http://www.bookmarkye.com/3.jpg" width="50px">
      </a>
      <span class="glyphicon glyphicon-left" aria-hidden="true"></span>
      <a href="{{ url_for('comment',user_id=foo.author.id ,num='1')}}"
      target="_blank">{{ foo.author.username }}</a>
      <br>
      <a href="{{ url_for('detail',question_id=foo.id) }}">{{ foo.title }}</a>
      <span class="badge">{{ foo.creat_time }}</span>
      <p style="">{{ foo.detail }}
      </p>
      </li>

      {% endfor %}
      </ul>
      {% endblock %}
      <ul class="list-group" style="margin-top: 30px;">
      <h1>全部评论</h1>
      {% for com in comment %}
      <li class="list-group-item" style="width: 800px">
      <a class="wrap-img" href="#" target="_blank">
      <img src="http://www.bookmarkye.com/3.jpg" width="50px">
      </a>
      <span class="glyphicon glyphicon-left" aria-hidden="true"></span>
      <a href="{{ url_for('comment',user_id=com.author.id,num='1') }}"
      target="_blank">{{ com.author.username }}</a>
      <br>
      <span class="badge">{{ com.creat_time }}</span>
      <p style="">{{ com.detail }}</p>
      </li>
      {% endfor %}
      </ul>
      <div class="list-group-item" style="margin-top: 30px;width: 800px;">
      <h1>名称:
      <small>{{ user2.username }}</small>
      </h1>
      <h1>问题数:
      <small>{{ questions|length }}</small>
      </h1>
      <h1>评论数:
      <small>{{ comment|length }}</small>
      </h1>
      </div>
posted @ 2017-12-15 09:54  064黄庚华  阅读(206)  评论(0编辑  收藏  举报