完成我的中心—導航標籤

    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>
      @app.route('/usercenter/<user_id>/<tag>')
      @loginFirst
      def usercenter(user_id,tag):
          user = User.query.filter(User.id == user_id).first()
          context = {
              'uername':user.username,
              'question':user.question,
              'comments':user.comments,
              'user':user
      
          }
          if tag == '1':
              return render_template('usercenter1.html', **context)
          elif tag == '2':
              return render_template('usercenter2.html',**context)
          else:
              return render_template('usercenter3.html',**context)
      % block body %}
          <ul class="zx">
              <li style="float: left;margin: 10px;list-style: none;" role="presentation"><a href="{{ url_for('usercenter',user_id = user.id,tag = '1') }}">question</a></li>
              <li style="float: left;margin: 10px;list-style: none;" role="presentation"><a href="{{ url_for('usercenter',user_id = user.id,tag = '2') }}">comments</a></li>
              <li style="float: left;margin: 10px;list-style: none;" role="presentation"><a href="{{ url_for('usercenter',user_id = user.id,tag = '3') }}">infomation</a></li>
          </ul>
          {% block usercenter %}
      
          {% endblock %}
      
      
      {% endblock %}
      
      {% for foo in comment %}
                      <ul style="padding-left: 0px;margin-bottom: 0px;">
                          <li style="width: 900px">
                              <a href="{{ url_for('usercenter',user_id = foo.author.id,tag=1)}}">{{ foo.author.username }}</a>
                              <span class="badge">評論時間:{{ foo.creat_time }}</span>
                              <p>{{ foo.detail }}</p>
                          </li>
                      </ul>
      
                  {% endfor %}
      <div class="meta">
           <a class="collection-tag" target="_blank" href="/c/1hjajt">{{ biaoqian }}</a>
           <a href="{{ url_for('usercenter',user_id = foo.author_id,tag = 1) }}">{{ foo.author.username }}評論:({{ foo.comments|length}})</a>
      
       </div>
相關文章
相關標籤/搜索