Hi,

I was wondering if it's possible to bring in an argument in a view to display the title as John Blog's Gallery, with realname being the argument.

Found the following which works with the core profile fields (but I'm using content profile module):

Under Add Argument- use the pull-down menu to select "User: UID is Author", click Add Argument button. Under 'Default' select "Display all values". Don't put anything in title field.

- In the "Argument Handling Code" text area add the code below:

The code

$uid = $argument;
if ($uid) {
$profile = db_result(db_query("SELECT value FROM {profile_values} v LEFT JOIN {profile_fields} f ON f.fid = v.fid WHERE f.name = 'profile_fullname' AND v.uid = '%d'", $uid));
if (!empty($profile)) {
drupal_set_title(check_plain($profile)."'s Photos");
return TRUE;
}
}
return FALSE;

Now you should see your 'fullname' profile field appearing as the view page title.

Is that at all possible please? Look forward to any reply, and thank you.
Lilian

CommentFileSizeAuthor
#6 realname-views-title-545658-6.patch691 bytesmarcp

Comments

liliplanet’s picture

Have been trying every which way .. can someone please help to have the argument title as realname please?

Would like the realname appear as a title in a view.

Look forward to any reply, and thank you.
Lilian

wilgrace’s picture

What was working for me for a while was to create an Argument for User: Uid, leaving everything default to display all.

I then put the argument reference (%1) in the Page Title, and that would then pull in the RealName.

This is now working for all profile pages that haven't been edited since Realnames was turned on, but those that are edited are given %1 as the page title

Not much help, but may help you find a way or sort it in the short term

liquidcms’s picture

sort of the same thing.. trying to get Realname as my views block title.. but maybe this is more an issue with Views than with Realname.

Anonymous’s picture

following

tchopshop’s picture

Using Views 3, trying to use an argument (contextual filter) to filter by author for a multi-user blog to display a list of months with the number of posts for that user on their user page.

I'm filtering by User:Uid and by Year + Month, but on the view that this archive links to, the title of the view is the Username not the Real Name. I have no idea how to change that.

marcp’s picture

Status: Active » Needs review
StatusFileSize
new691 bytes

There is a bug in realname_plugin_argument_validate_user.inc that is causing this to not work. If the argument coming in is numeric, then it doesn't pass a full user object to realname_make_name().

Patch is attached that fixes the issue in 6.x-1.x branch. Apply with:

  git apply realname-views-title-545658-6.patch

Status: Needs review » Needs work

The last submitted patch, realname-views-title-545658-6.patch, failed testing.

tchopshop’s picture

Thanks for your patch... Unfortunately, I'm using D7...

marcp’s picture

Status: Needs work » Needs review

#6: realname-views-title-545658-6.patch queued for re-testing.

marcp’s picture

@tchopshop, the module has been rewritten for Drupal 7 and this issue is tagged 6.x-1.x-dev.

I haven't run the D7 version yet, but the patch in comment 7 at #1170230: Views Exposed Filter for RealName 7.x looks like it might be worth a try for you. You may also have some luck with the latest patch in #1252538: Pass full user object to format_username() which addresses this in Views. You may need both of those patches.

The D7 code is much streamlined, but I suspect, since Views does not pass usernames back through theme_username() that we're going to need a little more Views code in the D7 realname module.

Status: Needs review » Needs work

The last submitted patch, realname-views-title-545658-6.patch, failed testing.

pvasener’s picture

Status: Needs work » Reviewed & tested by the community

I confirm that the patch #6 fixed the problem for me. I had to apply it manually though.

hass’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (outdated)