0

I need to implement hook_views_query_alter() to change the value of delta of the field that form a relationship.

As I posted in change delta value, the code is the following one.

   function supermama_misc_views_query_alter($view, $query) {
     $view->$query->table_queue['field']['join']->extra[2]['value'] = 1;
   }

It gives me the following error:

Fatal error: Cannot access empty property

The same error appears if I use the following code.

    function supermama_misc_views_post_build($view) {
      if ($view->name == 'gallery_images') {
        $view->$query->table_queue['field']['join']->extra[2]['value'] = 1;
      }
    }

What's wrong with the code? How do I bypass the error?

3
  • Please dpr() or var_dump problematic variable. Knowing what's in $view and in $query will tell us what's empty - and knowing what is empty is a key to tell how to make it full or to substitute it.
    – Mołot
    Commented Jun 29, 2013 at 23:06
  • the field is already has a value $view->$query->table_queue['field']['join']->extra[2]['value'] ans all parents also print_r() shows the contents of (objects and arrays ...etc) Commented Jun 30, 2013 at 6:05
  • If you will not share their content with us, there is hardly anything we can do with it. If property is not, in fact, empty but PHP says it is, it would be a PHP bug. But somehow I can't believe it.
    – Mołot
    Commented Jun 30, 2013 at 7:56

1 Answer 1

0

Thanks a lot molot

the problem was a wrong implementation to the views hooks as this post

and hook_views_query_alter

This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. MODULENAME.views.inc must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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