有没有更好的暴露过滤器的挂钩?

发布于 2024-12-19 04:28:36 字数 495 浏览 5 评论 0原文

我正在尝试修改“更好的暴露滤镜”的输出。当将排序选项显示为链接时,模块将始终输出用于升序降序排序的链接。我想删除每个排序标准的降序选项。

我在 better_expose_filters.theme 中做了一个丑陋的黑客攻击,它位于模块的目录中,如下所示:

function theme_select_as_links($vars) {

    //function does its stuff

    foreach ($element_set as $key => $value) {
        if (strpos($key, " DESC")) {
            continue;
        }
        //foreach loop does its stuff

    }
}

虽然这工作得很好,但显然是在错误的地方完成的。下一次更新肯定会打破它。我可以在模板文件中使用“更好的暴露过滤器”的钩子吗?

I'm trying to modify the output of "Better Exposed Filters". When displaying the sort options as links, the module will always output links for sorting ascending and descending. I'd like to remove the descending option for each sorting criteria.

I did an ugly hack in better_exposed_filters.theme, which resides right in the module's directory, like this:

function theme_select_as_links($vars) {

    //function does its stuff

    foreach ($element_set as $key => $value) {
        if (strpos($key, " DESC")) {
            continue;
        }
        //foreach loop does its stuff

    }
}

While this works just fine it's obviously done in the wrong place. The next update would certainly break it. Is there a hook for "Better Exposed Filters" I could use in my template file instead?

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

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

发布评论

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

评论(2

紫罗兰の梦幻 2024-12-26 04:28:36

你几乎就在那里!

Drupal 的工作方式是,任何以 theme_blah_blah 开头的函数都可以复制并直接放入自定义主题的 template.php 中。然后,您将实际调用从 theme_ 更改为 yourcustomthemename_

因此,在这种情况下,您有 function theme_select_as_links($vars) { ,您可以将其更改为 function myawesometheme_select_as_links($vars)

You are pratically there!

The way that Drupal works is that any function that starts with theme_blah_blah can be copied and placed directly into your template.php of your custom theme. Then you change the actual call from theme_ to yourcustomthemename_

So in this case you have function theme_select_as_links($vars) { which you would change to function myawesometheme_select_as_links($vars)

迷路的信 2024-12-26 04:28:36

查看:Erik Web - Hook 定义 并进行搜索位于模块内的钩子定义实现之上。这样你就可以找出每个可以使用的钩子。
我会选择:module_invoke_all、module_implements、drupal_alter、module_invoke

Have a look at: Erik Web - Hook definition and have a search above the hook definition implementation within the module. This way you can find out each hook that can be used.
I would go for: module_invoke_all, module_implements, drupal_alter, module_invoke

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