开发者

Drupal cck checkbox with global setting

开发者 https://www.devze.com 2023-01-15 11:20 出处:网络
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.

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"


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消