Hi all,

So I feel like this should be really easy to do, or at least I did when I started trying hours ago, but I may be wrong.

So I have a view the displays a recipe that a user has entered. Is there a way to set the Basic Setting: Title to be the Node: Title?

I think I'm just not seeing where this is set and the header is built.

Thanks,
Tristan

Comments

Are you saying a single recipe? Why not just display at node/{nid} where {nid} is the node id?

I think (and I'm just THINKING here) that setting the Title in Basic Settings: Title Gives you a fixed title. You could name it "Recipes" and if you print 10 recipes, this would be the header. If you are trying to get 10 recipes and each one to have the dynamic title, you might want to include the Node: Title as a field -- along with whatever else you are displaying. So each of the 10 would be Titled"Spinach Pie" "Beef Stew" etc.

Capiche?

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

So I have the node title field included, but I can't see how to set the basic setting of title to the value of the field for each recipe. So I can call it Recipes and they are all called that, and then do a title under it with "spinach pie", but I feel like it would be much cleaner if I could set the title to the node title for all of them. That way you not only "spinach pie" on the page, but as the page title and so forth.

One more thing that might help....

The default display in views is just a node. Look along the left edge of the window and add or see if there is a "Page" view. You may only be looking at the node view. (I don't know how much I am helping as I am a Views novice myself.)

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

Thanks mcfilms, but its a page already.

A lot of the fields can do things with string replace like use [title] to insert the title, but that doesn't seem to work with the basic settings, so who know. I'm sure I'll figure it out...

It really seems like you want to list nodes not fields.

That said, if you add "Node: title" as a field it displays the label (Title by default) and the title for the current node so am no sure what "So I can call it Recipes and they are all called that, and then do a title under it with "spinach pie"," refers to.

As for "That way you not only "spinach pie" on the page, but as the page title and so forth." once again it sounds like you are trying to display a single node (not a list) in which case using the nodes path may be more appropriate.

Hi Nevets,

Thanks for the replay, and yes I am just displaying a single node worth of data, but I'm using a some of views features for the display, and what fields are shown. Since I have a number of ways to look at each recipe based on who you are and how you get there this seemed like the easiest thing to do.

So when I set the basic settings title it displays at the top of the main content part of the page, in the title tag, in the header, and in the bread crumbs trail. It looks like there was a "not to bad" way to do set the title tag, and bread crumbs with views 1, but I can't figure out how to do it in views 2, with out using the basic settings.

Why not use CCK permissions to determine who can view what fields and/or theming in node-{content_type}.tpl.php (replace {content_type} with your content type), this seems easier to me.

Besides, I can think of an number of other reason I would want to be able to do this, so...

I think he meant html page title.

But this is what I followed to accomplish exactly what you are talking about.

http://www.davidnewkerk.com/book/18

I just replaced the word Articles with Recipes

Now I'm trying to take it a step further, which looks like others are interested as well: http://drupal.org/node/612468

I don't know if this is the right one but I think we share the same problem. I have a view that has a static title. I also have a taxonomy term which is based on views. What I want, is when I click on the taxonomy term I would also get that taxonomy term as the title on the page view.

How can I do this?

looking for the same

Subscribing

me too! This shouldn't be too hard given that it's possible to use the replacements like [fieldname] almost everywhere else.. then why not in the title.

Thanks!

subscribing
I'm looking in to some custom code to get this done.

See you at the The Do It With Drupal Seminar
Learn from the Lullabot Drupal Video Series

- Doug Vann
- http://www.dougvann.com My Blog
- SKYPE id: douglas.h.vann
- http://LinkedIn.com/in/dougvann
- http://www.twitter.com/dougvann Tweet Me

Hi guys,

Just so you know - this has been fixed by the Views people a while ago, see http://drupal.org/node/397358

I guess this is really a wrong place to post module-specific bugs/feature requests :)

Enjoy!

Hi,

Your link is a solution to a different type of problem. This problem does not involve Node Reference.

There are a number of reasons why you would want to dynamically set View Title based on -any- field or fields from your view results. Node.Title would be the most useful example field, but it is not the only field which would be useful in a title. The fact is, values from view results are not made available (at all) to anything in the Basic Settings area (not just View Title).

This does not mean that there is no solution at all. There is.

One solution that DOES work is to export your view (which you should do anyways for performance reasons). When the view is exported, you can edit the Views API code and set the page title that way. Depending on what you are doing for content, you MAY need to duplicate the same SQL query in your PHP (to arrive at the correct field[s]), then prepare a string for the title, then send that simple string as a Views API argument. Problem solved.

Not everyone wants to export their view, or folks do not want to do this during prototyping so that is one reason why this issue keeps coming up.

Also, Solving this in Views UI would allow you to dynamically set page titles in Panels also. Panels may set Page title based on a hardcoded value, Views Context (which does not work for this, due to argument context issue), or a hardcoded title string, OR.... Views Title. You can tell Panels to use the view pane's view title, and it works great. The core problem in that scenario is on topic to the original poster's problem of dynamically setting View Title (since an easy solution here would solve that issue also).

On IRC, Earl told me the re: views title issue: "The reason view titles can't use field data is mostly that it's never been done, and that using field data as part of the view title is generally only relevant with single row views."

Based on that answer, I would assume it will be done someday but it is not the most pressing priority (and for sure, there is a lot of development going on).

So for folks struggling with this or similar problems: Export your View
It is important to remember that Views UI is not Views. What I mean is, the Views UI is like a "wizard" that helps you do common tasks and it can shield you from PHP, most of the time.

The Views API (and the Views template layer) can do so much more than the Views UI. (One off-topic example to support this would be, some folks ask how to dynamically set the "Items to display" based on an argument. Views UI can not do that. But once you export the view, you can get the argument somehow in PHP, then pass that in as an argument to the Views API call, and this works.)

Hopefully this helps someone. For now, you can solve this, but only in code and not any GUI settings.

You can put php code in the "Header" part of "Basic Settings", like:

<?php
$view
= views_get_current_view();
if(
$view->result[0]) {
   
drupal_set_title($view->result[0]->title);
}
?>

This will set the page title dynamically.

Hope this helps.

This worked for me, though I used node_title instead. Thanks for posting.

<?php
$view
= views_get_current_view();
if(
$view->result[0]) {
   
drupal_set_title($view->result[0]->node_title);
}
?>

I also used node_title and it worked for me.

Thanks!

In Style output tpl file you can set the title based on -any- field or fields from your view results.
use $view variable to get the result set

drupal_set_title($view->result['0']->node_title);

The title could be dynamic without changing the views.tpl file or any altering code, if you want the title to be dynamic, this means that the page path will be dynamic, and this could be set from the view arguments and there you can set the page title as pattern i.e: %1 and depends on the page path the title will be.

and there is another way using this http://www.zyxware.com/articles/644/change-the-page-title , but I recommend the first solution.

omar-swe

Yes Omar you are correct! I believe this is the solution lot's are looking for.
Thanks!

Indeed it works. If only the field description was explaining that much...

"Any sufficiently advanced technology is indistinguishable from magic."
Arthur C. Clarke

For D7 we can do it in view Advance ->contextual filter.have options to Override title .so we will able to Override the view and other argument titles.like %1 first argument.
Hth