It should appear in the docs.php at least and have more mention in the api*html advanced help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Still outstanding AFAICT - http://views.doc.logrus.com/

dawehner’s picture

Status: Active » Needs review
FileSize
0 bytes

Here is a basic first version.

dawehner’s picture

but this time.

webchick’s picture

Status: Needs review » Needs work

I got clued into this hook from #372994: Ability to INNER JOIN to node for a specific field and went searching for docs and found this post.

Things I was looking for when looking for this documentation:

1. What's in that $data array so I don't have to print_r() it to find out?
2. When does this hook fire?
3. Why should I generally use it?
4. (my specific question) How can I change a join type?

I don't really know that any of those questions were answered by the current documentation.

In the examples, it would be nice to use something a bit more "real world" to give people a clue on what to do with this hook. If I end up figuring this out at all, I'll post back with an alternative patch, but please don't wait for me. ;)

newalexandria’s picture

'Riding a bit sidecar' to @webchick, I don't have a huge demand for making INNER JOINs on a specific field due to the low priority of my current task – but if I could do it, it might help the way I do many other things. If anyone can post answers to her 4 questions above, that would be very helpful

joachim’s picture

A few answers:

> 3. Why should I generally use it?

If another module has defined the table and you want to add a field.
Eg, your module provides a snazzy field on users. But {users} is already defined by Views core on behalf of user module. So you can't define your field in hook_views_data, you have to use this hook and add to the existing user key.

> 1. What's in that $data array so I don't have to print_r() it to find out?

Whatever modules put into it in hook_views_data. Same structure.

gdoteof’s picture

subscribing

whikloj’s picture

I am wondering if anyone can explain why using an else if

function contains_argument_views_data_alter(&$data){
	foreach ($data as $table_name => $table){
		if (preg_match('/^profile_values/',$table_name)){
			if ($data[$table_name]['value']['argument']['handler'] == 'views_handler_argument_string'){
				$data[$table_name]['value']['argument']['handler'] = 'contains_argument_handler_argument_string_contains';
			} else if ($data[$table_name]['value']['filter']['handler'] == 'views_handler_filter_in_operator' || 
			  $data[$table_name]['value']['filter']['handler'] == 'views_handler_filter_profile_selection'){
				$data[$table_name]['value']['filter']['handler'] = 'contains_argument_handler_filter_taxonomy_profile_selection';
			} 
		}
	}
}

doesn't work, but if I separate it into 2 ifs...

function contains_argument_views_data_alter(&$data){
	foreach ($data as $table_name => $table){
		if (preg_match('/^profile_values/',$table_name)){
			if ($data[$table_name]['value']['argument']['handler'] == 'views_handler_argument_string'){
				$data[$table_name]['value']['argument']['handler'] = 'contains_argument_handler_argument_string_contains';
			} 
			if ($data[$table_name]['value']['filter']['handler'] == 'views_handler_filter_in_operator' || 
			  $data[$table_name]['value']['filter']['handler'] == 'views_handler_filter_profile_selection'){
				$data[$table_name]['value']['filter']['handler'] = 'contains_argument_handler_filter_taxonomy_profile_selection';
			} 
		}
	}
}

If works perfectly?

I spent a couple hours debugging this before I tried this on a whim. Maybe I missed a piece of documentation?!

merlinofchaos’s picture

From the looks of it, you always want both clauses to run since you modify both the 'argument' and 'filter' values of the table; with your 'else' only one of them can run.

matt2000’s picture

Status: Needs work » Reviewed & tested by the community

While I agree that answers to webchick's questions would be nice enhancements, dereine's Patch in #3 provides the minimum needed to make use of this hook. There's no reason to wait for 'perfect' documentation when we've got 'good enough' sitting here waiting to be committed, and *nothing* in docs.php currently.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs work

I agree. I've gone ahead and committed the minimal work so far, because having something is better than having nothing.

If someone would like to step up and expand this based upon the comments, I would really appreciate that. To that end, I am returning this to 'needs work' status in the hopes that someone will move on this.

esmerel’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Needs work » Active

Moving this back to an active status; webchick's questions need answering, and nobody looks at stuff in 'needs work' :)

Ben Coleman’s picture

Looks like this still isn't documented, almost a year later. Having this documented would have definitely saved me some time.

merlinofchaos’s picture

Status: Active » Fixed
joachim’s picture

Title: hook_views_data_alter is not documented » hook_views_data_alter is not fully documented
Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Fixed » Active

The page http://api.drupal.org/api/views/views.api.php/function/hook_views_data_a... exists; the URL you gave doesn't ;)

It could still do with the $data array param being documented though.

merlinofchaos’s picture

Documenting the $data param there would be wasteful. It's the same as in hook_views_data -- at best it should have an @see.

dawehner’s picture

Status: Active » Needs review
FileSize
433 bytes

Does this makes it a bit easier to understand?

tim.plunkett’s picture

FileSize
686 bytes

The @see is redundant, I think this is enough.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
merlinofchaos’s picture

I don't think the @see is redundant actually. Lots of people seem not to understand what will be in that param.

tim.plunkett’s picture

FileSize
811 bytes

Well, then I think its just the URL itself. The @see is already two lines below it, and doxygen needs it to be there.

merlinofchaos’s picture

Agree with RTBC now.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

It's in! Thanks for the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.