if nothing else, a short "what is different" to ease developers coming to this project from Views Custom Field would be a good place to start.

the single text field has been split into a few smaller text fields, and the number of places that you can drop PHP into your view has increased; it takes a few hours of trial and error to figure out what they're all for at this point.

a few snippets of example code for common use cases (based on what comes through this issue queue) would be great too.

Comments

screenage’s picture

Subscribing

eloivaque’s picture

Subscribing

jsibley’s picture

Even one example in the issues queue would be helpful in understanding what goes where.

For example, snippets showing how to make a field lower case or concatenating two text fields would give some idea of what goes under values and what goes under output?

Could anyone post an example of something simple you have gotten to work?

thedavidmeister’s picture

there are some examples in the issue queue, but if they're working the issue is usually immediately marked as "closed (fixed)", so have a bit of a trawl through those instead of the open issues.

jsibley’s picture

I spent quite a while looking through the issues queue and was not able to find a simple example that helped.

Hoping that this might help someone else, here is what I was able to put together for one of my websites:

Value

$str = $row->realname;
$str = preg_replace('/\W+/', '-', $str);
$str= strtolower($str);
return $str;

Output

 print $value;

This assumes that the realname module is being used. It also assumes that realname is unique enough to be useful as a link.

I wanted to slugify the realname to use it as link text. By placing this field before the realname field, I can then use this field as link text. The view that is linked to uses realname as an argument, with the spaces to dashes option.

No doubt, there are other ways of doing this, but everything under users/ on my site is off-limits to anonymous users, and I wanted to allow some users to have public profiles.

I'm not sure if there would have been a reason to add setup code. In any case, I didn't see how to use it, so I left it out.

thedavidmeister’s picture

Maybe comment #1 from #1406078: Question - why is it better to create a plugin yourself? could go into the README file? It is good advice and is probably not obvious to a lot of people using this module.

@jsibley - here's a simple example that took me less than a minute to find #1069418: Views PHP Sort howto? that also helps explain how sorts work which is a little more complex than simply returning a string for a field output.

If you're looking for general PHP advice this isn't the place to ask for it.

if you want to see the structure of what you have available just do a print_r() on one of the variables provided (like $row).

If you want to check that your "realname" module exists before trying to use it, use module_exists() or just check the return of empty( $row->realname );

either way, I think that your use case would be too niche as it has a clear dependency on another module, so it probably can't be used in the README for this module. With that in mind, it might be best to open another issue for your situation and see if you can get help there.

jsibley’s picture

@thedavidmeister, I wasn't actually asking for help now. What I did works for me, as I wrote.

I understand about the dependency issue, but the example you refer to seems more complex to me. I had already seen it and did not find it helpful.

Nonetheless, the module is helpful once one figures out how to use it. There is so little documentation that I thought someone might find my example helpful. If not, so be it.

Liam Morland’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is no longer supported. If this applies to a later version, please re-open and update the version.