Created
April 6, 2011 09:29
-
-
Save Lothiraldan/905390 to your computer and use it in GitHub Desktop.
Add support for pagination in notmyidea-cms theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8790b3702910236185f6fd08f39420ace407e69e Mon Sep 17 00:00:00 2001 | |
From: FELD Boris <lothiraldan@gmail.com> | |
Date: Wed, 6 Apr 2011 11:27:22 +0200 | |
Subject: [PATCH] Add support for pagination in notmyidea-cms theme | |
--- | |
notmyidea-cms/templates/index.html | 20 +++++++++++++++----- | |
notmyidea-cms/templates/pagination.html | 12 ++++++++++++ | |
2 files changed, 27 insertions(+), 5 deletions(-) | |
create mode 100644 notmyidea-cms/templates/pagination.html | |
diff --git a/notmyidea-cms/templates/index.html b/notmyidea-cms/templates/index.html | |
index 2a06ed8..838ae50 100644 | |
--- a/notmyidea-cms/templates/index.html | |
+++ b/notmyidea-cms/templates/index.html | |
@@ -2,15 +2,19 @@ | |
{% block content_title %}{% endblock %} | |
{% block content %} | |
{% if articles %} | |
-{% for article in articles %} | |
- {% if loop.index == 1 %} | |
+{% for article in articles_page.object_list %} | |
+ {% if loop.first %} | |
<section id="content" class="body"> | |
<aside id="featured"><article> | |
<h1 class="entry-title"><a href="{{ SITEURL }}/{{ article.url | |
}}">{{ article.title }}</a></h1> | |
{% include 'article_infos.html' %} | |
{{ article.content }} | |
- </article></aside><!-- /#featured --> | |
+ </article> | |
+ {% if loop.length == 1 %} | |
+ {% include 'pagination.html' %} | |
+ {% endif %} | |
+ </aside><!-- /#featured --> | |
{% if loop.length > 1 %} | |
<h1>Other articles</h1> | |
<hr /> | |
@@ -29,9 +33,15 @@ | |
</div><!-- /.entry-content --> | |
</article></li> | |
{% endif %} | |
+ {% if loop.last and (articles_page.has_previous() | |
+ or not articles_page.has_previous() and loop.length > 1) %} | |
+ {% include 'pagination.html' %} | |
+ {% endif %} | |
{% endfor %} | |
-</ol><!-- /#posts-list --> | |
-</section><!-- /#content --> | |
+{% if loop.length > 1 or articles_page.has_previous() %} | |
+ </ol><!-- /#posts-list --> | |
+ </section><!-- /#content --> | |
+{% endif %} | |
{% else %} | |
<section id="content" class="body"> | |
<h2>Pages</h2> | |
diff --git a/notmyidea-cms/templates/pagination.html b/notmyidea-cms/templates/pagination.html | |
new file mode 100644 | |
index 0000000..edcda43 | |
--- /dev/null | |
+++ b/notmyidea-cms/templates/pagination.html | |
@@ -0,0 +1,12 @@ | |
+<p class="paginator"> | |
+ {% if articles_page.has_previous() %} | |
+ {% if articles_page.previous_page_number() == 1 %} | |
+ <a href="{{ SITEURL }}/{{ page_name }}.html">«</a> | |
+ {% else %} | |
+ <a href="{{ SITEURL }}/{{ page_name }}{{ articles_page.previous_page_number() }}.html">«</a> | |
+ {% endif %} | |
+ {% endif %}Page {{ articles_page.number }} / {{ articles_paginator.num_pages }} | |
+ {% if articles_page.has_next() %} | |
+ <a href="{{ SITEURL }}/{{ page_name }}{{ articles_page.next_page_number() }}.html">»</a> | |
+ {% endif %} | |
+</p> | |
\ No newline at end of file | |
-- | |
1.7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment