Django- CMS: Plugin position in a placeholder

拟墨画扇 提交于 2019-12-10 15:18:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!