Download & Extend

Using arguments from one view to fill panel page title

Project:Panels
Version:5.x-2.0-alpha14
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

Hi,
At first, very, very thanks for this great module, and alpha14 seems to be very stable. Thanks a lot.
I use panels 2 with great pleasure and it accomplishes almost everything I would like.

I am missing one feature which is possible with views (or I am overlooking possible documenation how to get things done).

I will explain the situation:
- I have a panel with a couple of views embedded. some custom blocks embedded all with the taxonomy terms as arguments
- I have one main view in which I set the view-title related to the arguments (taxonomy terms in my situation, with a complex argument handling code). Apart from the breadcrumb coming up twice this is working as should.

Now I want the view-title set in the argument handling code to appear in the panel. But I am not getting this to work. I looked at the context tab and the arguments handling there, but I couldn't figure it out.

Code in my views argument handling is:

$view->page_title = $tmpterms_0[0]->name . ' ' . $tmpterms_1[0]->name . ' ' . $base_url;

Could I use this $view->page_title to overrule the panel page $page->title ?
If so, how can I achieve this?

greetings,
Martijn

Comments

#1

Category:support request» feature request

Hmmm. If you have the taxonomy terms as arguments, you can use the keyword replacements from the context it generates. I'm not sure that's going to be flexible enough for what you need, however.

And right now, there's no easy way to get the title from the view all the way back to the panel page directly. Hmm. This will take some work, I think. I'll have to think on it.

#2

Hi Earl,

It would be great to have the views argument handling code flexibility into panels.
I mean the same functionalitiy as say argument handling with filters usage in views, in which you can get to the filter by using the array with the number of the filter (from 0 to ..)
For instance, just as an example:

$tmpterms_0 = taxonomy_get_term_by_name(arg(1));
$tmpterms_1 = taxonomy_get_term_by_name(arg(2));
// place id of term (second of array) into second filter’s value
$view->filter[2][value][0] = $tmpterms_0[0]->tid;
//the same for third filter
$view->filter[3][value][0] = $tmpterms_1[0]->tid;
// change of depth if necessary
$view->filter[2][options] = 3; // or any other integer
$view->filter[3][options] = 3; // or any other integer

What I can see is to have a panels argument handling as the view argument handling code
2 possible examples of panels argument code:
1)

$tmpterms_0 = taxonomy_get_term_by_name(arg(1));
$tmpterms_1 = taxonomy_get_term_by_name(arg(2));
$page->title = $tmpterms_0[0]->name . ' ' . $tmpterms_1[0]->name;

or

2)

if (%arg1)   
   $page->title = $panels->pane[11][title][0] ( 11 = 1 for Top and other 1 for first pane..)
  (and in the panels pane 11 code is said if the pane title is taken over the title from the view, etc..)

This would be great functionality for panels I think, and makes it a very flexible instrument, right?
I don't know if this is doable, off course, but this argument handling code which is used in views is very flexible. I think it is brilliant!

Off course I am also very interested how to use the %keyword in the context area of panels 2? Is there an working example already? Do I need to type in the %keywords myself in the context area, that will not be workable for me, because I use the panel as a flexible instrument which is filled with views and blocks related to the arguments. And the arguments are taxonomy terms.

Thanks in advance!

Greetings,
Martijn

#3

Well, the keyword functionality creates keywords from contexts. So yes, you fill in the keyword on a context (and it suggests one for you that it knows is unique) and you can use %thatkeyword in titles across panels.

Since there currently isn't a place in Panels like the PHP Argument Code, I'm not sure there's a good place to do what you're asking.

#4

Note that there are two hooks that could possibly work for what you're doing: hook_panels_pre_render and hook_panels_post_render

You get the $display; if it's a panel page, the page will be in $display->owner

You'll get every display that renders, so you'll have to keep track of which is which, but checking $display->owner->name should tell you what exactly is being rendered.

Your panes will be $display->content[$pid]. You should just dump $display -- there's a lot of interesting info in it.

#5

Hi Earl,

I can see this code in panels alpha 14. Will this give me the title of the specific pane, to set in page title?
How to get this "imported in a panel? Is this the code I need to get to the title of a pane, to set in the page->title?

$page->title = panels_get_pane_title($display->content[283], $display->context)

283 is my panel-pane from which I want the title to be shown as page-title.

So I export the panel I already build. Change this code, and then import it? Will this work? ..no..
I tried it but I think right now it is impossible to overrule the page_title (or other variables programmatically?

Is there a way to not import it programmatically?
Thanks for your reply!

greetings,
Martijn

#6

Subscribing b/c I'd like this functionality too.

#7

Hi all, Earl,

This is working for me in views AND panels.
Adding this with above shown argument handling code is working.

..
drupal_set_html_head('<title>'. $tmpterms_0[0]->name . '</title>');
drupal_set_html_head('<meta name="description" content="' . $tmpterms_0[0]->name . '"
/>');
drupal_set_html_head('<meta name="keywords" content="' . $tmpterms_1[0]->name . '" />');
etc..

Does anybody use this sort of code to get the meta-description and meta-keywords programmatically filled?

The only thing is I have to get rid of the title and metatags put in the page-header because of the nodewords added wrong metatags, and normal view->panel title inheritence.

I can do this in the theme in page.tpl.php with:

<?php
 
if (arg(0) == 'view' && arg(1) == 'some-list') {
   
$head = preg_replace('/"to be replaced string"/', '"replaced string"', $head);
  }
  print
$head
?>

But I think this is inefficient, right? Is there another way.

Is it possible to get rid of the title from views/panels?
Is there a way to -not-set- the nodewords for a particular page, as is possible with other items like nodes within Drupal. Does anybody have a patch for this?

Thanks for your reply!

greetings,
Martijn

#8

Version:5.x-2.0-alpha14» 5.x-2.0-alpha1

Hi Earl,

I see that if I leave the page_title blank in panels 2 alpha 14, it takes the site_name for head_title.
My first question is this correct?

Second question could this not be altered so that if I set in a view the following argument handling code this title is used in the panel? With a chain reaction panel-title=pane-title=view-title

$view-title = "Panel title"; ==> or any variable within the view.

Of course then there should be one option more in a pane. And that is set the pane title to be the panel title.

This way the most flexible situation is arising.
1) Giving a panel a title
2) No panel title typed. Giving panes the option to alter the title. (if for one pane the title is set to override the panel-title, the other panes shouldn't have this option anymore).
3) No panel title typed. No pane title typed. Because of the already available pane-view title inheritence. Giving the panel the title of the pane, and because of the 2 options checked the title will be the title of the inserted view in the pane.

Will this be possible?
Thanks for your reply!
Greetings,
Martijn

#9

Version:5.x-2.0-alpha1» 5.x-2.0-alpha14
Component:User interface» Code

Changed accedentially from panels 14 to panels 1. Changed it back again now.

Hi Earl,

I got it solved with a 95% solution.
I got rid of the $head_title out of my theme. I was not able to override this one with drupal_set_html_head, don't know why.
Now the title is set through the following argument handling code in my view in my pane in my panel :)

drupal_set_html_head('<title>' $New_Title '</title>');

The only problem is in other pages the $head_title is also gone..
So I would very much like an orderly solution like asked through using a pane's titel as panel titel with which I can keep the $head_title (because I asume this one is overwritten then..) in my theme page.tpl.php.

Thanks for your reply in advance,
greetings,
Martijn

#10

Hi guys,

I'll throw this out here in hopes that the all-mighty merlin will see it. I am having a great deal of difficulty wrapping my head around how to effectively use panels and views. I have looked EVERYWHERE possible for good articles/podcasts and have come to no avail...

I make various content types and assign all nodes to a taxonomy hierarchy that starts [usually] with the basic pages like "Home", "About", "Contact", etc... and then build the terms deeper and deeper. That is how I filter nodes in Views and sort them by category weight.

Is this a good method?

Furthermore, should you have panels initially inside views or vice-versa?

I'm not asking you to write a long response... please I don't want to waste anyone's time. If you guys could provide an AWSOME link that would be soooooo helpful! Thanks a lot and keep up the great work! This community is amazing!

#11

ANGRY DONUTS !!! Merlin you are da shiznat! I Just found some of your articles and man they help! I didn't see you could choose "Panels" in the "page" fieldset in views....

#12

Martin: I have no way to affect $head_title one way or another. I can only use drupal_set_title() and the $head_title is calculated from that along with the page title. So there is nothing Panels can do here; you have to control that exclusively in your theme, unfortunately.

(Checking panels_page_get_current() might help), maybe.

pegleglax: A fair question but it needs to be in its own issue; we need to keep issues focused. Please create a new issue and set its Category to 'support request'. Thanks.

#13

Status:active» closed (won't fix)

Hi Earl,

It is working with the method I described. The only thing is that it will not be the highest possible line in my source code what google spiders, but that is not a big issue.
Thanks for your remarks!

I noticed there is a module coming, may be to solve this issue...
www.drupal.org/project/panels_titles ?
The owner of the module will try to make a panels 2 version he said. Are you aware of this module?
Will this module solve this issue nicely?

Greetings,
Martijn

#14

I wanted the argument that i use in one of my contexts and in my views to appear as an h1 title on the page and in the title tag. I just filled in 'term' as the keyword in the context and '%term' as the title of the panel. Works as expected.