使用引导程序自定义主题和夹层获取博客条目 [英] Fetch blog entries with bootstrap custom theme and mezzanine

查看:98
本文介绍了使用引导程序自定义主题和夹层获取博客条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是夹层的新手,我设法安装了自定义的引导程序主题,只是将模板和静态文件复制到了django应用程序的亲戚文件夹中.

I'm new to mezzanine, I managed to install my custom bootstrap theme just copying templates and static files in the relatives folders in my django app.

假设在index.html中,我有一些类似这样的博客条目

Assume in my index.html I have some blog entries like these

<h2>Other Entries</h2>
<article>
<h3>Blog Post 1</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>
<article>
<h3>Blog Post 2</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>
<article>
<h3>Blog Post 3</h3>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text.... <a href="#">Read more</a></p>
</article>

如何获取以前在管理页面中插入的博客条目?

How can I fetch my blog entries I've previously inserted in the admin page?

谢谢

推荐答案

在模板顶部放置:

{% load blog_tags %}

然后,无论您希望在何处显示博客帖子,都将显示以下内容

Then wherever you want the blog posts to show up put something like the following

{% blog_recent_posts as recent_posts %}
{% for blog_post in recent_posts %}
<h3>{{ blog_post.title }}</h3>
{{ blog_post.description_from_content|truncatewords_html:10|safe }}
<a href="{{ blog_post.get_absolute_url }}">Read more</a>
</article>
{% endfor %}

无耻的插头: 我正在撰写一系列博客文章,这些文章描述了如何为夹层创建主题的过程.进行检查, http://bitofpixels.com/blog/mezzatheming-creating-mezzanine-themes-part-1-basehtml/

Shameless plug: I'm in the middle of writing a series of blog posts that describes the process of how I create themes for Mezzanine. Check it out, http://bitofpixels.com/blog/mezzatheming-creating-mezzanine-themes-part-1-basehtml/

这篇关于使用引导程序自定义主题和夹层获取博客条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆