问题
I was looking for a way to check the plugin's position within a placeholder in Django-CMS. I found this question Detect last plugin in a placeholder
Is "plugin" a django cms keyword? I can't find documentation about it.
My question is: How can I obtain information about the plugins rendered within a Placeholder?
Thanks
回答1:
if you don't override your plugins render method (2.4 and up), you'll have your plugin as instance
in your context. using the following, you'll get the 1 based position of your plugin:
{{ instance.get_position_in_placeholder }}
also interesting: is_first_in_placeholder
and is_last_in_placeholder
. in fact, @paulo already showed you the direction in his comment ;) this is the code, with new line number: https://github.com/divio/django-cms/blob/develop/cms/models/pluginmodel.py#L382
来源:https://stackoverflow.com/questions/12977863/django-cms-plugin-position-in-a-placeholder