Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: sophie_links_siblings_of not working

Prior to this fix, the tag only worked for sophie_entry_list_url page
due to its assumption that the format of the reversed url is fixed.

But generally the url contains a slug certain part of the blog,
as apposed to sophie_entry_list_url, which contained not such.
  • Loading branch information...
commit a78d5279a718c66658b85883c04ca09964c157c9 1 parent 41921be
@dduan authored
View
2  sophie/templates/sophie/default/category_details.html
@@ -24,6 +24,6 @@
</div>
<div id="pagination">
- {% sophie_links_siblings_of page blog 'sophie_category_details_url' %}
+ {% sophie_links_siblings_of page blog 'sophie_category_details_url' category.slug %}
</div>
{% endblock main %}
View
14 sophie/templatetags/sophie_parts.py
@@ -14,18 +14,26 @@ def sophie_shows_feed_of(blog):
return { 'blog': blog }
@register.inclusion_tag('sophie/templatetags/links_siblings_of.tag')
-def sophie_links_siblings_of(page, blog, urlname):
+def sophie_links_siblings_of(page, blog, urlname, part_slug=None):
# conditional operatior hack xx and yy or zz == xx ? yy : zz
url_bits = multiblog_enabled and { 'blog_slug': blog.slug } or {}
+ # urls are named following this convention:
+ # sophie_[part name]_[page type]_url
+ # which is taken advantage of here:
+ urlparts = urlname.split('_')
+ # if the type is 'details', then its url contains a slug of the part
+ if urlparts[2] == 'details':
+ url_bits['%s_slug'%urlparts[1]] = part_slug
+
# Note that previous_page_number() is dumb, it returns the number
# regardless of whether that page exists, same with next_page_number.
# So, this needs to be guarded in the template
url_bits['page_num'] = page.previous_page_number()
- previous_link = reverse( urlname, kwargs=url_bits)
+ previous_link = reverse( urlname, kwargs=url_bits )
url_bits['page_num'] = page.next_page_number()
- next_link = reverse( urlname, kwargs=url_bits)
+ next_link = reverse( urlname, kwargs=url_bits )
return {
'previous_link': previous_link,
Please sign in to comment.
Something went wrong with that request. Please try again.