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

dawehner’s picture

You can always query direct to the users table, but its not so elegant.

boblangdon’s picture

I 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.

merlinofchaos’s picture

Status: Active » Fixed

If you're using a User: UID argument, just setting the title field (in that argument) to "%1's blogs" should do what you want

boblangdon’s picture

Hmmm...

That puts it in my browser title bar -- which is good!
But still not on the page.

merlinofchaos’s picture

That 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.

boblangdon’s picture

Of 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

merlinofchaos’s picture

The user_load will be a bit heavier.

boblangdon’s picture

Status: Fixed » Closed (fixed)

Thank You Mr. Merlinofchaos!