Hello,

First and foremost, thank you very much for a great module and the support base!

I was wondering if it is possible to get the initial of the last name in a field.
i.e. Last name: Johnson => to show as "J." in the field

Thank you very much in advance!

Comments

casey’s picture

echo $data->node_data_field_lastname[0] . '.';

or

echo substr($data->node_data_field_lastname, 0, 1) . '.';
Bilmar’s picture

Hello casey!

Thank you for the quick support.

Using the above code I am only seeing a " . " for the field in the view.
I'm sorry I forgot to mention that I am using content profile (if it may have an impact on the code).

Also, is it necessary to have any arguments/relationships?

I apologize but not familiar with php programming, and currently starting to learn from guides available online.

Thank you!

casey’s picture

1. You have to add the lastname field to the view (and exclude it from display).
2. I am just using an example variable. You have to find out what the name of the needed variable is. For this you can use

print_r($data);
Bilmar’s picture

From what I have learning from php guides in the past week, it just clicked from your explanation!
I will try adding lastname field to the view and exclude it from display, then print_r to get the variable.

As a side note - would this be the only way of doing this?

Thanks casey!