具有全局设置的 Drupal cck 复选框
我正在为我的内容类型“新闻”创建一个“粘性”复选框。这意味着一个新闻节点是粘性的,并且用在像横幅这样的盒子中。
这由 cck 创建内容表单中的复选框标记。
该复选框由 node_api 处理,
因此我检查: if $op = 'update' and $node->type = 'news' then ... 逻辑。
我不知道为什么,但这似乎不是最好的方法,因为我所有的 noe 处理都是在那里完成的。
有没有更逻辑的方式/地方来处理这个问题?
@edit,
我还必须创建一个额外的模块来激活它。我有一个“通用”模块,可以处理一些通用的事情”
I am creating a "sticky" checkbox for my content type "news". this means that one news node is sticky, and is used in a banner like box.
This is marked by a checkbox int the cck create content form.
The checkbox is handled by the node_api,
so I check: if $op = 'update' and $node->type = 'news' then ... logic.
I don't know why but this doesn't seem like the best way to do it, because all my noe handling is done there.
Is ther a more logic way/place to handle this ?
@edit,
I also have to create an extra module to activate this. I have a "general" module which handles a few of this general things"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我为存储 Node_ID 的即时贴创建了一个 set_variable。
这样,当我将内容项设置为粘性时,所有其余内容都将变为“不粘性”。
就像魅力一样。
I created a set_variable for the sticky which stores the Node_ID.
This way, when I make a content Item sticky all the rest is made "Unsticky".
Works like a charm.
如果您需要在创建新的“新闻”节点时取消设置“粘性”复选框,那么这可能是最直接的方法。我还没有尝试过,但您也许也可以使用规则和操作模块来做到这一点。
如果在将新的“新闻”节点设置为粘性时不需要取消设置旧的“粘性”字段,那么您可以只使用返回设置了粘性字段的单个最新“新闻”节点的视图。然后就可以显示查看结果了。
If you need to unset the "sticky" checkbox when a new "news" node is created, then yes this is probably the most straightforward way. I haven't tried it, but you might be able to do that using the Rules and Actions modules as well.
If you don't need to unset the old "sticky" field when a new "news" node is set as sticky, then you could just use a View that returns the single most recent "news" node that has the sticky field set. Then you can display the View results.