[support] User name in title of View?

Shai Gluskin shai at content2zero.com
Fri Oct 2 21:00:34 UTC 2009


Steve,

Though what I wrote before will work... it is actually a lot easier to get
what you want. You don't have to create the second view at all to write that
URL.

In the first view provide by Views module In the argument settings for
"node: user posted or commented" you need to select, "Provide default
argument" and then one of the choices is: "User ID from logged in user" and
voila... All you need to provide in a menu or anywhere is: bettertracker and
then it will rewrite itself to bettertracker/2 (where "2" is the user id of
the logged in user).

You can read a lot more at: http://drupal.org/node/404742

That discussion starts off about the conflict between the Tracker module and
the tracker view and then ends up expaining a lot. The guy on the thread
"Bob" is really helpful.

Shai

On Fri, Oct 2, 2009 at 4:44 PM, Shai Gluskin <shai at content2zero.com> wrote:

> Steve,
>
> First off, yes... this stuff IS confusing, so pat yourself on the back.
>
> Next... the Views module already creates the view you are looking for you
> and gives it to you "for free" as part of the Views install process. It's
> grayed out, sitting at the bottom of:
>
> /admin/build/views
>
> It's called "Tracker". Click "Enable". At that point what I would do is
> "clone" it and then disable the one you enabled. That way you have a "pure"
> version of what comes with Views.
> *
> Note: Drupal core's "Tracker" module has the same path that the Views
> "tracker" view has. That's a bug! (on Views part). Anyway, just make sure
> that the Tracker module is turned off or that you rename the Views path to
> something other than "tracker."*
>
> Re: the URL. Yah you get there via the URL. So if you renamed the tracker
> view to better-tracker, then the URL would be example.com/better-tracker/2where "2" is the UID for user/2. The View will return the user name in the
> Title, just like you wanted.
>
> But then you ask... how can I dynamically create that URL? Now it's time to
> create *another* view which is a "User" view and you filter on "current
> user." For output you select "fields" and then "User: id". You likely also
> want to choose another field: "User: name." For "user: id" select, "hide
> from display." Then for "user: name" you select, "rewrite the output of
> field" and write a link  better-tracker/[uid] with the link text something
> like, "See content for [name]. (Note: the order of the fields, uid and name
> doesn't matter. But what is critical is that you have to rewrite the output
> of the second field in order to have both variables available to you.)
>
> Then you put that view in a block or whereever and it will have the one
> link in it for the current user and will be properly titled as will the view
> that it links to. If you want people to see more than their own list of
> content, you can, of course, set the filter on your user view differently.
> *
> The trick about the argument for the initial node view:*
>
> The trick is that the argument is NOT user: name or any of the other user
> arguments. Rather, the argument you use is: "node: user, posted or
> commented". Yup, confusing.
>
> Let us know how it goes!
>
> Shai
>
>
> On Fri, Oct 2, 2009 at 3:27 PM, Steven Scotten <steves at splicer.com> wrote:
>
>> Wow, this is awesome but also a little confusing.
>>
>> The title of the argument overrides the title of the page, cool. But I'm
>> still not clear about getting at the value of the argument.
>>
>> I have to choose an action to take if argument is not present, and for
>> some reason the argument is never present. Does this mean I have to add the
>> argument to the URL? That defeats the purpose of using the name of the
>> current user.
>>
>> When I looked at the form for configuring the argument User: Name, the
>> first thing I tried was putting "%1" in the title. I can choose "Provide
>> default argument" as the Action To Take if Argument Is Not Present, and then
>> use PHP code , but that seems like I'm doing way too much for what you
>> described as a simple setting.
>>
>> Sorry if I'm being dense.
>>
>>
>> Steve
>>
>>
>> On Oct 2, 2009, at 11:52 AM, Shai Gluskin wrote:
>>
>>  Steve,
>>>
>>> This is what Views "arguments" were created for. Make the user  an
>>> argument. The argument settings allow for dynamic content, based on the
>>> argument, to be used for the page title.
>>>
>>> Shai
>>>
>>> On Fri, Oct 2, 2009 at 2:48 PM, Luciano Rossi <lukio at gcoop.com.ar>
>>> wrote:
>>> Steven Scotten escribió:
>>>
>>> This seems like a simple enough thing, but I'm plum stumped.
>>>
>>> I've created a view of all a user's content, and I'd like to include the
>>> username in the title of the displayed page. I've tried using token and
>>> variable syntaces and both simply display the actual characters I typed, not
>>> substituting the username.
>>>
>>> Is it true that the title of a Page created by Views has to be static
>>> text and cannot include data about the content displayed?
>>>
>>> Hello, you can write php code at the head of the view if you enable the
>>> php filter.
>>>
>>> Cheers!
>>>
>>> --
>>> Luciano Rossi
>>> gcoop - Cooperativa de Software Libre
>>> www.gcoop.com.ar
>>> (0054 11) 4856-7925 Luis. M. Drago 364 3 B
>>>
>>>
>>>
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/support/attachments/20091002/03c189c5/attachment.htm>


More information about the support mailing list