Drupal:更改视图参数

发布于 2024-09-11 12:23:47 字数 291 浏览 2 评论 0原文

我广泛搜索以找到解决此问题的可行解决方案,但找不到。

我想要做的是更改传递给视图的参数,因为我希望将 pathauto 清理后的分类术语用作参数。我有一段代码可以将清理后的术语转换回原始术语,但无法使视图使用它。

我看到有些人在 hook_preprocess_views_view(&$vars) 中更改了它,但就我而言(Views 2.11)在 $vars 中有一个参数实例化了很多次,以至于它不是方式。

谁能帮我改变这个论点吗?

I searched far and wide to find a working solution to this but couldn't find it.

What I want to do is change the argument that is passed to the view because I want for pathauto cleaned taxonomy terms to work as an argument. I have a code that transforms cleaned term back to a original one, but cannot make the view use it.

I saw some people changing it in hook_preprocess_views_view(&$vars) but in my case (Views 2.11) has a argument in $vars instanced so many times that it's not the way.

Can anyone please help me change this argument?

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

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

发布评论

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

评论(3

我最亲爱的 2024-09-18 12:23:47

可能有更好的方法,但您可以使用views_embed_view()并自己设置参数

There may be a better way but you could use views_embed_view() and set the arguments yourself

少女的英雄梦 2024-09-18 12:23:47

我有两个想法,要么向视图参数的 phpcode 部分添加一些自定义 php 代码来执行类似的操作

$args[0] = 1;
return $args;

,要么尝试使用未测试它们的函数

hook_views_pre_view(&$view, &$display_id, &$args) {
  // modify $args value here
}

,因此不知道哪个会起作用。

I have two ideas, either to add some custom php code to the view's argument's phpcode section that does something like this

$args[0] = 1;
return $args;

or try to use the function

hook_views_pre_view(&$view, &$display_id, &$args) {
  // modify $args value here
}

didn't test them so don't know which will work.

清风无影 2024-09-18 12:23:47

我认为 hook_views_pre_view 可能会帮助你做到这一点。

I think hook_views_pre_view might help you do just that.

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