Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.11
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Jan 2009 at 09:37 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent
Comments
Comment #1
lazly commentedIts work, please migrate to doc.
Comment #2
ducdebreme commentedDo you have a suggestion, where to put it? ...
... here http://views-help.doc.logrus.com/ ?
Or somewhere else?
Stefan
Comment #3
dawehner@ducdebreme
http://views-help.doc.logrus.com/ is a checkout of the advanced-help in views. So you suggest to put it into views, which i think is good. This might be needed often.
Alternative there could be a handbook-snippet-section for views, like for the drupal-5 version, but i prefer the first one, even there are people ignoring advanced help. There should be a more offensive display in views, when the advanced module isn't installed.
Comment #4
lazly commented@ducdebreme
I dont know where is the bigest views doc, maybe somewhere here: http://drupal.org/node/322506
Bye!
Comment #5
merlinofchaos commentedRTBC means there's a patch attached.
Also, $handler->set_option('title') will work better than directly modifying the title, since that won't work for overridden displays.
Comment #6
scalp commentedIs there a way to insert two arguments into the title? For example, "$argument1 in $argument2". Seems like with the need to change the $handler variable this wouldn't be possible.
Comment #7
ice5nake commentedI've tried the following from within hook_views_pre_render
//DOES NOT WORK
$view->display_handler->set_option('title', $title);
//DOES NOT WORK
$view->display[$view->current_display]->handler->options['title'] = $title;
//DOES NOT WORK
$view->display[$view->current_display]->handler->set_option('title', $title);
Can't figure this out. Thanks so much for any insight.
Comment #8
ice5nake commentedI moved
$view->display_handler->set_option('title', $title);
to hook_views_pre_build and now it works.
The new problem, it doesn't change the title for feed display types.
Comment #9
merlinofchaos commentedMaybe setting the title in the $view->build_info would work? The title does get set there, I think, or at least information about it does. I thought.
Comment #10
ice5nake commented@merlinofchaos The title is how I want it in the build_info. So that's not where the problem is.
Comment #11
ice5nake commentedScratch that. This is exactly where it needed to be changed.
Comment #12
dawehnerThis is techical a support issue
Comment #13
summit commentedSubscribing, needing to be able to change title of node_view to the related taxonomy term name.
greetings, Martijn
Comment #14
xjmI tried #7, #8, and #9 -- none seemed to work. The hooks are called, but nothing I try seems to change the page title.
I need to be able to set the page title dynamically based on the result set, so I'm not sure
hook_views_pre_build()would allow that anyway.I know that there were a number of API changes in 2.8; is it possible that there's a different method to use in the current release?
Comment #15
xjmHere's an alternate solution. Instead of setting the view title, I just overrode the title with the core API.
Not sure what other repercussions this might have, and I guess it only will work for a page view, but it's the only thing I've tried so far that actually changed the title.
Comment #16
dawehnerI think this is fixed now. There are serveral ways provided how to do it.
Comment #17
xjm#16: No, none of the ways provided work in 6.x-2.11, at least not in any view I've tested. My solution is a workaround and will not work for anything other than the main page view.
Comment #18
Letharion commentedAssigning to myself as I'm gonna try to get this into the docs.
Comment #19
glass.dimly commentedbump.
where is this?
Comment #20
goofrider commentedFound a solution that works.
http://www.zyxware.com/articles/644/change-the-page-title-of-a-view-in-d...
BTW it has to be in the full form (note the code reference a specific page display):
I tried to use:
But that doesn't work. Maybe $handle->argument is not an object.
Comment #21
Steven Brown commentedI am currently using panels to display two views on a single page. The only suggestion from above that will
change the title for me is the following.
Only issue with this is it changes both of the view titles. I want to be able to change each title. I have one view but two different displays which is why I am assuming the above code doesn't work. Seems to apply it to all display titles.
If anyone has an idea to do what I'm asking please let me know.
IRC Name: FatGuyLaughing
Thanks in advance
Comment #22
merlinofchaos commentedTest $view->current_display and set the id based upon display title?
Comment #23
Steven Brown commentedAlright I have found out how to do this in case anyone else wants to know.
First make a module. In you mymodule.module file put the following code.
Components:
Where it says 'view_machine_name' this is the name that you give the view when you create a new one.
Where it says 'display_machine_name' this is the name that views has given it's display. More than likely you don't know what this is. In order to find out just put a drupal_set_message('
'); statement at the beginning of the hook_views_pre_build() function. Now visit the page that has this view being displayed. Follow the hierarchy of the view object. You printed out $view so don't look for that. Instead look for the display array. In that array will be display objects. Each of these have a name. Find the one that is your display. If the display is a page display then the naming convention is this page_#. So page_1, page_2, etc.
The reason for checking that you have the right view object is so you don't get any errors. This is the error you will get if you don't check.
Error:
Fatal error: Call to undefined method stdClass::attach_to() in /var/aegir/platforms/worx_business-6.x-1.0-alpha4/profiles/worx_business/modules/contrib/views/includes/view.inc on line 1008
If you use the function hook_views_pre_render() and you don't check the view you will get an error that deals with stdClass::destroy()
Hope this helps guys.
Comment #24
Steven Brown commented#22, Sorry merlin I've been trying to write the #23 comment for a couple of hours or so and didn't refresh to look if someone had posted back.
Comment #25
reinis.berzins commentedDoes anyone have an idea how to change the MENU TAB TITLE using the same method?
I tried the following three ways, but apparently none of them is correct:
$handler->options['menu']['title'] = 'MY NEW TITLE';$handler->tab_options['title'] = 'MY NEW TITLE';$handler->menu['title'] = 'MY NEW TITLE';Comment #26
Steven Brown commentedI don't believe this will work due to the view creates the menu item. After that I don't believe you can override it from the $view object. I believe at this point you would need to use hook_menu_alter() in order to change the title. However, if you are already trying to do this through the $view object then you are in code so it would be easier to do the hook_menu_alter().
Hope this helps!
Comment #27
reinis.berzins commentedThanks! This custom module code works! However it breaks cron, login, save node, flush cache and all other operations (except browsing from page to page) on my website. In the log I find the following error:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.I tried to restrict this custom module to work on certain paths only like node/%, but with IF statements in the code it stops working at all:
P.S. I also tried you simpler version with static title
$items['node/%views_arg/questions']['title'] = 'Questions';, but the same error happens.Comment #28
Letharion commentedBefore this thread gets any longer, I'm going to point out that it's about setting "View-Title", which is not what the discussion is currently about.
I will close this as fixed, as of #26. Unfortunately I haven't taken the time to document this this.
If you have further questions regarding _the title_, please re-open.
Otherwise open a separate issue.