Drupal 6 预处理块和节点

发布于 2024-08-21 23:10:50 字数 431 浏览 5 评论 0原文

我构建了一个位于网站右侧且可用于整个网站的 BLOCK

我还得到了许多CONTENT_TYPE NODES,例如(页面、新闻、图库、文件)

如何修改 _preprocess_xxxxx 以及哪一个,以便我可以让我的 BLOCK 知道当前正在显示哪个 CONTENT_TYPE

所以我的 BLOCK 显示 var $section = top 10 download for CONTENT_TYPE==files; 对于 CONTENT_TYPE==news,我将在我的块 var $section 中看到最新新闻。 等等,等等...

I build a BLOCK that sits on a right side of the website and is available for whole site.

Also I got a many CONTENT_TYPE NODES like (pages, news,gallery, files).

How can I modify _preprocess_xxxxx and which one, so I can let my BLOCK know which CONTENT_TYPE is currently displaying.

so then my BLOCK displays var $section = top 10 download for CONTENT_TYPE==files;
and for CONTENT_TYPE==news, I will see latest news in my block var $section.
etc, etc...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

方圜几里 2024-08-28 23:10:50

您可以使用预处理来解决此问题,但由于您已经创建了自己的块,因此从块代码中处理此问题要容易得多。

您可以使用 arg 来检查块是否正在显示在节点上,然后检查该节点是什么类型。不过,您必须禁用该块的缓存,否则它将无法工作。

You can use a preprocess to solve this, but since you have made your own block it is a lot easier to handle this from within the block code.

You can use arg to check if the block is being displayed on a node, and then check what type that node is. You'll have to disable the cache for the block though, or else it wont work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文