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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | realname-views-title-545658-6.patch | 691 bytes | marcp |
Comments
Comment #1
liliplanet commentedHave 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
Comment #2
wilgrace commentedWhat 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
Comment #3
liquidcms commentedsort 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.
Comment #4
Anonymous (not verified) commentedfollowing
Comment #5
tchopshop commentedUsing 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.
Comment #6
marcp commentedThere 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:
Comment #8
tchopshop commentedThanks for your patch... Unfortunately, I'm using D7...
Comment #9
marcp commented#6: realname-views-title-545658-6.patch queued for re-testing.
Comment #10
marcp commented@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.Comment #12
pvasener commentedI confirm that the patch #6 fixed the problem for me. I had to apply it manually though.
Comment #13
hass commented