Skip to Content
Menu
This question has been flagged
1 Reply
2919 Views

I have created a block that displays "blog posts" on home page, now when I click on a particular post, I want user to be redirected to the blog page with the specific record opened up (the one user clicked). I am using v8, how do I do that -

blogs1 = []      
for blo in request.env['blog.publish'].search([]):
            blogs1.append(request.env['blog.post'].search([('name','=',blo.blog_title_id.name)]))      
            if blogs1:
                b1=blogs1[0]          
                b2=blogs1[1]          
                b3=blogs1[2]                  
            else :
                b1=False          
                b2=False          
                b3=False
      values = {
                 'b1':b1,
                'b2':b2,          
                'b3':b3
        }
     return request.render('website.homepage', values)<section>               <div class="bx-viewport">                               
    <div class="left">                     
         <div class="recent_blog">                         
             <h2><strong>Recent</strong> from the blog</h2>                                                       
            <div class="post_block">                               
                <t t-foreach="b1" t-as="record">                                   
                <a t-att-href="keep('/blog/blogpost/%s' % slug(blog) class="thumb">
            <span itemprop="image" t-field="record.image" t-field-options='{"widget": "image"}'/></a>                                                        <h5><a href="/blog"><t t-esc="record.name"/></a></h5>                                       
                <div class="date"><span><t t-esc="record.write_date"/></span></div>                                   
                <div class="post"><p><t t-esc="record.subtitle"/></p></div>                                                                 
             </t>                           
    </div>                           
        <div class="post_block">                                                                   
            <a  t-att-href="keep('/blog/blogpost/%s' % slug(blog) " class="thumb">
                    <span itemprop="image" t-field="b2.image" t-field-options='{"widget": "image"}'/></a>                                   
                    <h5><a href="/blog"><t t-esc="b2.name"/></a></h5>                                   
            <div class="date"><span><t t-esc="b2.write_date"/></span></div>                                   
            <div class="post"><p><t t-esc="b2.subtitle"/></p></div>                                                           
    </div>                         
             <div class="post_block last">                                                                   
    <a t-att-href="keep('/blog/blogpost/%s' % slug(blog) class="thumb">
        <span itemprop="image" t-field="b3.image" t-field-options='{"widget": "image"}'/></a>                                   
            <h5><a href="/blog"><t t-esc="b3.name"/></a></h5>                                 
         <div class="date"><span><t t-esc="b3.write_date"/></span></div>                                   
    <div class="post"><p><t t-esc="b3.subtitle"/></p></div>                                                           
</div>                           
<div class="clear"></div>                     
 </div>                      
</div>         
<section>

Avatar
Discard
Best Answer

You will have to create a controller with this mention route /blog/blogpost/<model("blog.blog"):blog>/   

Like

@http.route('/academy/<model("academy.teachers"):teacher>/', auth='public', website=True) def teacher(self, teacher):

        return http.request.render('academy.biography', { 'person': teacher })

Avatar
Discard