开发者

Context module for block visibility

I have a site built in Drupal 6 that requires a number of blocks that are only visible to certain roles or on specific pages. Normally, I would use the block configuration settings to control page and role visibility. However I recently ran across the context module that effectively splits the site into "sections" or "groups" of related attributes.

My question is: When is it appropriate to control block vis开发者_JAVA技巧ibility from context rather than the block configuration settings? Should I only use one or the other or a combination of both?


these are different approaches meant for different use cases, but they are not mutually exclusive.

context indeed splits the site into different contexts (and there is also the possibility of context types). and that is effectively its use case: context-based block showing/positioning.

however context won't check for user roles nor multilingual settings (i18n). block supports these cases (and you can combine both context and block to show something on a context depending on user role).

block also allows users to choose whether they want to see the box or not.

my final answer is: combine instead of choosing.


There is no hard and fast rule for when to use core block placement, and when to use context. In general though, if you have a lot of blocks, with different and complex visibiity logic, context will make things more manageable. Additionally, contexts can be exported to code, which allows one to more easily track block configurations in version control. When storing contexts in code, this also allows changes to blocks to be deployed to a production site by simply updating the code, rather than needing to log in and manually move things around via the UI.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜