Getting title of ancestor

13 views
Skip to first unread message

est

unread,
Dec 30, 2011, 7:10:50 AM12/30/11
to Django FeinCMS
Hi all!

There is the feincms_parentlink tag that returns the link to an
ancestor of the page. But there is no tag for the title of that
ancestor. I suggest that's because it is very obvious, but I could not
find how to do that.

Can anyone tell me how to get ancestor title for the passed page?

est

unread,
Dec 30, 2011, 7:25:08 AM12/30/11
to Django FeinCMS
I just found this way:

{% for entry in main %}
{% if entry|is_equal_or_parent_of:feincms_page %}
{{ entry.title }}
{% endif %}
{% endfor %}

But I think there must be more neat way to do that.
What do you think?

Martin J. Laubach

unread,
Dec 30, 2011, 8:23:16 AM12/30/11
to django-...@googlegroups.com
If you want just the title of the immediate parent, that would be

{% if feincms_page.parent %}
{{ feincms_page.parent.title }}
{% endif %}

If you want all the parents, something like this should work

{% for p in feincms_page.get_ancestors %}
{{ p.title }}
{% endfor %}


est

unread,
Jan 2, 2012, 5:20:45 PM1/2/12
to Django FeinCMS
Intuitively I suspected something similar to this, thank you again!


On 30 дек 2011, 17:23, "Martin J. Laubach" <goo...@emsi.priv.at>
wrote:
Reply all
Reply to author
Forward
0 new messages