0

I have a content type, have a integer value field suppose field name is "field_xyz" and I have also variable from variable tables (variable_set('xyz')) which have some dynamic value

Now I want to create a view in which I need to add a filter and showing all node having field_xyz's value greater than equal to variable_get('xyz') value. I can do this using views_php module but I want to do it with manual configuration (No PHP code). Is there anyway ?

1

I won't recommend views_php module. This will hamper performance of the site.

You can use hook_views_query_alter(&$view, &$query) for this. What you have to do is - add field_xyz filter inside view, and override it in hook_views_query_alter(&$view, &$query).

| improve this answer | |
  • Thanks Subhojit777 for your help But I need something do it by contrib module I don't want to do by custom code – Akash Jain Apr 22 '16 at 10:32
  • 1
    Any reason you don't want to use custom code? Drupal provides it's own API so that we can build something that is not available out of the box. – subhojit777 Apr 22 '16 at 18:55
0

You can do it with 2 extra modules installed: Variable and Views arguments in filters

You need to install the sub-module of Variable called Variable views

Provides views integration for variable, included a default variable argument.

Via it you can add a default value to the contextual filter as a Variable.

As you want to do a value greater than equal to comparison you will need the Views arguments in filters module:

Using the "Views arguments in filters" module, you can use placeholders when configuring filters, like so:

  • Node: Title CONTAINS %1
  • Node: Post date >= %2
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.