开发者

OR in view's argument -- How to rewrite views query?

开发者 https://www.devze.com 2023-01-01 22:13 出处:网络
I need an OR clause in the arguments section of a view.So if a user passes 123, I\'d like to return ro开发者_开发技巧ws WHERE Field1 = 123 OR Field2 = 123.

I need an OR clause in the arguments section of a view. So if a user passes 123, I'd like to return ro开发者_开发技巧ws WHERE Field1 = 123 OR Field2 = 123.

I'm fairly certain this can't be done in the views interface (but please correct me if I'm wrong).

So I'm trying to rewrite the query. Where's the best place to do this?

I'm in hook_views_pre_execute(&$view) right now, but it looks like this would mean using text replacement on the final SQL string!

Is there a cleaner way to do this?


You could try the Views Or module, or consider this other post.


I've answered a similar question here

Basically you can use either views_or module or hook_views_query_alter.

0

精彩评论

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