2016-11-25 3 views
0

私はカスタムの最新のブログテンプレートを作成しました。しかし、サムネイルで表紙画像を表示することはできません。オドーブログカバーの画像が表示されない

表紙画像は、ここでは次のようになります。

enter image description here

私が書かれている表紙画像表示するようにコードを次のようにそれをロードしていないコードイメージを書き込んだ後

<div class="panel"> 
    <t t-set="properties" t-value="json.loads(post.cover_properties)"> 
     <a class="o_panel_cover" t-attf-href="#{blog_url('', ['blog', 'post'], blog=post.blog_id, post=post)}" t-att-style="background-image: #{cover_properties.get('background-image')};"> 
     </a> 
    </t> 
    <div class="panel-heading mt0 mb0"> 
     <h4 class="mt0 mb0"> 
      <a t-attf-href="#{blog_url('', ['blog', 'post'], blog=post.blog_id, post=post)}" t-field="post.name"></a> 
      <span t-if="not post.website_published" class="text-warning"> 
      <span class="fa fa-exclamation-triangle ml8" title="Unpublished"/> 
      </span> 
     </h4> 
    </div> 

をこのように表示されます:

enter image description here

イメージを表示するにはどうすればよいですか?

+0

:次のように返されますt-attf-style = "background-image:#{cover_properties.get( 'background-image')};" これは、noneタイプのオブジェクトはattrubute getを持たないと言います。 –

答えて

0

まず、コントローラにはいくつかのことがあります。

最新のポストルートがカバー性質をレンダリングしていない、それは以下のようなものです:

return request.render("website_blog.latest_blogs", { 
     'posts': posts, 
     'pager': pager, 
     'blog_url': blog_url, 
    }) 

だから、私は、コントローラに必要な機能を追加し、次のように返さ:XMLで

return request.render("website_blog.latest_blogs", { 
     'posts': posts, 
     'pager': pager, 
     'blog_url': blog_url, 
     'blogs':blogs, 
     'blog_posts': blog_posts, 
     'blog_posts_cover_properties': [json.loads(b.cover_properties) for b in blog_posts], 
    }) 

を `:私は次のように入力した場合にも、

<t t-set="cover_properties" t-value="blog_posts_cover_properties[post_index]"/> 
    <a class="o_panel_cover" t-attf-href="#{blog_url('', ['blog', 'post'], blog=post.blog_id, post=post)}" 
     t-attf-style="background-image: #{cover_properties.get('background-image')};"></a> 
0

ブラウザのキャッシュをクリアすることをお勧めします。キャッシュ過負荷のために画像が取得されないことがあります。

+0

それは確かにそうではありません。 –

関連する問題