Hi,

I want to give a specific page title to my blog front page which is generated from views. Here's the code I used in page.tpl.php:

global $current_view; 
// show custom page title for blog_frontpage and blog_archive views
if ( $current_view->name == ('blog_frontpage' || 'blog_archive ') ) {
	echo 'My blog title';
} else {
// show the default $head_title for all other pages
	print $head_title;
}

This works find but I run into a problem when I use the block view for blog_frontpage and blog_archive. The blocks are embedded on other pages but it still returns $current_view as blog_frontpage and triggering 'My blog title'.

I can easily get around this by using a different view for my blocks but I think it would be useful to know how to determine if a page is a View. Thanks, and Happy New Year!

Comments

sun’s picture

Status: Active » Closed (won't fix)

Sorry, unfortunately this support request is way too specific. Please have a look at the issue queue - Views maintainers are buried already. You might want to try to get further support at http://drupal.org/support.
If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.

suffering drupal’s picture

Status: Closed (won't fix) » Active

Ehm SUN, this is not specific at all.
It is of general interest so after more than 2 years I considered activating it again. Answering it should be extremely simple for you or any other maintainer/developer/author/contributor, so why "delegate" it?

What is the code to detect whether the current page is a view??
For use in blocks for example.

Somewhere I found:

 
global $current_view; 
// show custom page title for blog_frontpage and blog_archive views
if ( $current_view->name == ('blog_frontpage' || 'blog_archive ') ) {
    echo 'My blog title';
} else {
// show the default $head_title for all other pages
    print $head_title;
}

but adapted to my situation:
if ( $current_view->name != ('feeds_data_01') ) {
return TRUE; // block will be shown

it's not working. Did I do something wrong or is the code I found wrong?
Could this take 5 minutes of your knowledge or is this actually too *simple* to attend to?

merlinofchaos’s picture

Status: Active » Closed (won't fix)

Drupal 5 is no longer supported. Re-opening issues against it won't help.

suffering drupal’s picture

¿¿¿Why not straight answers instead of rejecting with so much ease???
I am convinced it would take about the same amount of characters so it wouldn't wear your keyboard....

By the date of my post you might have understood that I DO mean Drupal 6, but since you command I will open up a NEW CASE to ask: "what is the code to detect the current page is a view"