Django- CMS:占位符中的插件位置 [英] Django- CMS: Plugin position in a placeholder

查看:68
本文介绍了Django- CMS:占位符中的插件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方法来检查插件在Django-CMS中占位符的位置。我发现了这个问题在占位符中检测到最后一个插件

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

插件是django cms关键字吗?我找不到有关它的文档。

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?

谢谢

推荐答案

如果您不覆盖插件的渲染方法(2.4及更高版本),则在您的上下文中将您的插件设为 instance 。使用以下内容,您将获得插件的基于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}}

也很有趣: is_first_in_placeholder is_last_in_placeholder 。实际上,@ paulo已经在您的注释中向您显示了方向;)这是代码,并带有新的行号: https://github.com/divio/django-cms/blob/develop/cms/models/pluginmodel.py#L382

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

这篇关于Django- CMS:占位符中的插件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆