Support For Views
irstudio - September 19, 2007 - 17:40
| Project: | Page Title |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | nicholasThompson |
| Status: | needs work |
Description
it would be nice to be able to specify a different page title for views as well
1) line 194 of the module would have to say
if (drupal_is_front_page() || !$page_title) {
because the view might not have a drupal_title
2) i suppose a form alter for the view edititng page would be needed as well
3) also an extra column for the page_title table to handle vid
4) not sure, but there has got to be a way to hook into the view load operation and set the page title

#1
Interesting idea! Should be fairly easy to do - I'll look into how Nodewords handles meta data for almost all page types...
#2
Has anyone had any luck with this?
#3
I haven't had time to look at this yet. Its something I'd like to integrate into PageTitle2...
#4
bump, quite a silently in-demand feature, actually! I thought it sounded like a must have, so i talked to other SEO-savvy drupallers to see how they've been getting by without it... most have been doing work-arounds, like getting the PHP code for a view, pasting it into a new Page from which they CAN control the page title.
#5
i need that too.
i use 'title' with pathauto in mind,
'page title' is exactly that what i want to display.
#6
My work around is much simpler. Check out the Insert Views module (http://drupal.org/project/insert_view). Although it is very easy to just make a page and display a View within it, it's a few extra steps and it would be great to see Page Title exposed to Views.
#7
I attach a patch which has been lightly tested...
Feedback needed and appreciated.
Basically this patch adds a field to the page fieldset of a view where you can set the Head Title of the view. The patch also reworks the way the the module stores the page titles - so upon patching you will need to run a database upgrade. DO NOT TEST THIS ON LIVE! The database update changes the ID field from 'nid' to 'pid', adds a new column called 'type' and recreates the primary key.
What probably needs doing is defining either a default view token template and/or a token template for all views. Maybe (just as a thought) the Head Title should also allow tokens too? This might allow you to say [term-name] in the Head Title which would make things like the taxonomy/term override better... But the issue is making the token_replace aware of the scope (node, taxonomy, user, etc).
Anywho - thoughts?
#8
Here is a second patch with fixes/improvements. It is also re-rolled against ALPHA5....
Please review!
#9
I have noticed some errors in the patch and am working on this right now... will post another patch later this morning.
#10
Ok, more fixes are here...
Checkout DRUPAL-5--2-0-ALPHA5 version of PageTitle, patch it with this patch and then run update.php as this required changes to the database table.
DO NOT RUN THIS ON A LIVE SERVER!
Each view will now have a field called "Head Title" where you can provide the title for the View. You can use tokens in the head title... So, for example you could define the View Head Title as "Term: [cat]" which will cause every "taxonomy/term" page to use the term name in the title...
Apart from testing this and providing feedback, one thing that we need to figure out is how to handle arguments as tokens... The way I am doing it right now is I am checking all the arguments that the view can take against all the arguments provided and doing one token_replace on each one - although currently its only programmed to handle the "taxid" argument.
Thoughts?
#11
Hi Nicholas, thanks for the patch. I tried it on alpha5 and ran update.php but the views page title do not work it displays the default patterns. Perhaps I copied the patch incorrectly, if possible can you please upload the full install and module files including patches?
Thanks
#12
I'll give it a go at some point.
Nick
#13
Hi, any progress in this field please?
greetings,
Martijn
#14
Views are essential to a well-structured Drupal site. BUT...
The biggest problem is that while a view generates a web page, it doesn't provide the same control over it that is available in any normal node/page. That's a huge shortcoming, easy to see from the many postings here and elsewhere about hacking views.
The Page Title module is also essential. So, modifying it to handle views is an urgent need.
#15
It is an "in progress" part of the DRUPAL-5--2 branch which is currently an "in progress" snapshot... I'm working on it but dont have a massive amount of free time at my disposal.
#16
subscribe, I need too this very useful patch ;-)
#17
What is the status of this feature request in d6?
#18
It's (for me at least) "in progress when I have a spare day"
If anyone here is headed to DrupalCon Szeged - I'd be interested in having a chat with you about this!
#19
+1 for this request. This would be really great!
#20
I created a table views. it shows an error message for anonymous user while it's working fine for authenticated users.
Here is the error message: » warning: Invalid argument supplied for foreach() in :\hshome\myname\modules\views\theme\views-view-table.tpl.php on line 22.
Even if I configured the block to be visible for both.
Thanks
#21
Moving this down to a normal priority as the "patterns for paths" issue (#289389: Advanced token replacement based on path for page titles) would be a quicker and easier solution in the immediate future until I get a chance to play with Views 2 more...
#22
Hi, WHat is the status of this ? I am running drupal 5.x and certainly needs this module to get rid of that sitename in views titles. any suggestions ?
#23
Using Page Title 2, you can configure the "default" Page Title pattern to be just the [title] or [page-title]. This will remove the Site Name from all pages, including views.
The "Support For Views" issue is actually so people can define a View Title and a View Page Title separately.
#24
So, I didn't underststood, in tha release candidate 2.0 there will be this feature?
Hoping so,
#25
The problem with implementing Views page title's is figuring out the scope of the View (is it a view of nodes by user, taxonomy, date, location... etc).
Page Title 2.0 will contain a feature to configure page titles for a URL based on certain token "scopes"... It's a "work in progress".
#26
thks, I'll wait for the 2.0 release.
#27
subscribing
#28
Hi, is this in the cards for 6.x? Thanks.
#29
It is - just needs time...
#30
Thank you, but currently views titles is completely f'ed up. Is there a way to restore titles to doing the default thing but for views only?
#31
Is there a date when we could a expect a version of "Page-Title" with Views integration? I am sorry for not beeing a helpful hand but my PHP knowledge is very limited.
#32
Unfortunately there is no date.... Sorry.
#33
Subscribing! It'll be nice to have that functionality since hacking views can be a pain at times.
FYI, the easiest way I found to deal with different page titles and view titles is by inserting the view into a page node. Just follow this instructions http://drupal.org/node/336097 and optimize the page as if you were optimizing it with the page title and meta tags modules :)
The following snippet unfortunately did not work since it changes both titles:
<?phpdrupal_set_title("YOUR_TITLE_HERE");
?>
If you have any other php hack, please share it. Thanks
#34
Is there any feature to at least a page number on views pagers now for d6??
Thanks
#35
Hi,
It would be great if the views-title would be supported by page_title. This way theming the termtitle, nodetitle and viewstitle would be better equiped through pagetitle!
Greetings, Martijn
#36
@patchak: Page Numbering is coming... Waiting for #224262: Add Page Number token...
@Summit: Not sure what you mean. View's title gets set through drupal_set_title() which in turn is picked up by Page Title if the page is not a node, term or user (or front)....
#37
Views picks up the default title defined by page title. The page number patch for D6 tokens is two lines of code and works fine with D5. I now append the page number to the default pattern which means all my titles will have a 1 at the end, unless a pager is active (eg in views).
Views integration would mean I could restrict the token to views with an active pager, and I might be able to include tokens for filter terms on a case by case basis.
#38
I see! So you'd like to specify different View token patterns...
I'll take a look at some point.
#39
Any worked solution for use Page title in Views?
Thanks.
#40
As far as I know: No! Also still looking for working solution!!
#41
Solved! Page Title by Path.
http://www.seodrupal.org/drupal-seo-modules/page-title-path
#42
Hi, will you put your module also on drupal.org? Thanks for building this!
Greetings, Martijn
#43
AWESOME!! Thank you so much! I will give it a try this week! Coming back for feedback!
GREAT WORK!
#44
interesting. subscribing
#45
Subscribing need badly. Not sure if #41 works with latest version of node words as latest version makes meta by path obsolete and besides Page Title by Path is for Drupal 5, need a 6 solution.
#46
A potential breakthrough for Views integration...
<?php
elseif (($menu_item = menu_get_item()) && ($menu_item['page_callback'] == 'views_page')) {
$args = $menu_item['page_arguments'];
$name = array_shift($args);
$display_if = array_shift($args);
if ($view = views_get_view($name)) {
$view->set_display($display_id);
$view->pre_execute($args);
$title = $view->get_title();
}
}
?>
I added this to a test site in
page_title_get_title. This allows Page Title to correctly pickup the title generated by Views when you're on a page with an argument. Now all we need is to add a field to the argument panel + a function to the object to get the data processed and returned! Hmm...