I have a view pane displaying a user's blogs in their profile page.
The "more" link leads to a page view where I'd like to include an h1 header with the user's name in it.
This works in the Page Header field:
<h1>
<?php
$view = views_get_current_view();
$var1 = $view->args[0];
$my_user = user_load(array('uid'=>$var1));
print $my_user->name;
?>
's Blogs</h1>But I suspect there's a more efficient way to do this without needing to invoke "user_load."
THX
Comments
Comment #1
dawehnerYou can always query direct to the users table, but its not so elegant.
Comment #2
boblangdon commentedI considered that approach, but I figured it would still use just as many resources that way. Seems to me, with the uid already contained in the view's default argument, that I could use that to somehow get the user name (owner of the blogs) from the view. Unfortunately, I'm having a hard time understanding how Views arguments work.
Comment #3
merlinofchaos commentedIf you're using a User: UID argument, just setting the title field (in that argument) to "%1's blogs" should do what you want
Comment #4
boblangdon commentedHmmm...
That puts it in my browser title bar -- which is good!
But still not on the page.
Comment #5
merlinofchaos commentedThat would be a problem with your page template, then; by default the page title and the head title are the same, in Drupal, and Views can't affect that.
Comment #6
boblangdon commentedOf course.
I forgot I disabled $titles in page.tpl.php (purposely).
I was hoping there might be s simple ay to add
print #some_variable;to the header html field (since the uid has already been used and Views conveniently converts uids to user names).Oh well.
So which of the above options would be a bigger demand on resources, invoking the "user_load" function or a direct db query to the users' table?
Thanks Again
Comment #7
merlinofchaos commentedThe user_load will be a bit heavier.
Comment #8
boblangdon commentedThank You Mr. Merlinofchaos!