Is there a way to get the context argument to a custom content pane?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Manuel Garcia's picture

Hi all,

I am in a bit of a dead end here, first a brief description of our case:
2 taxonomies: artist and album
4 content types: artist, album, song, and video pulling from those taxonomies.
node overriden for all through panels2
context puling arguments for taxonomy IDs on those nodes, from both vocabularies, that drive all views panes.

This all works great (got to love panels2), but there is one piece I cant seem to get working:

I aim to have a pane on artist node overrides, that will have a flashplayer, with all videos tagged with the same artist term id, as a playlist.

I have the playlist through a xspf_playlist view, that takes taxonomies IDs as arguments, and that is working fine.
I plan on doing a custom content pane, in php, that will do something like this (using the flvmediaplayer and swfobject_api modules):

<?php
 
// I've simplified this code so that only the relevant part is here for my question
  
$playlist = '/video_playlist/' . $argument// $argument needs to be the context taxonomy ID passed by panels2
  
$url = "/sites/all/modules/flvmediaplayer/mediaplayer.swf"; //path to flash file
  
$params = array('width' => 300, 'height' => 300 );
  
$vars =  array(
    
'playList' => base_path() . path_to_theme() . $playlist,
    );
   print
theme("swfobject_api", $url, $params, $vars);
?>

What I can't get is the argument. I have searched around the api, without much success ...
I need to know whether there is a way to pass the context taxonomy id to a custom content pane somehow, if there is a function available for this or how to go about doing this.

Comments

Checkout these 2 links. I

Doktor.Science's picture

Checkout these 2 links. I think they may help.

http://drupal.org/node/241344

http://groups.drupal.org/node/10894

Unfortunately, those links

sdboyer's picture

Unfortunately, those links are only generally relevant at the level of building a music/album/artist-related site; they don't bear on the direct question in the OP, which is the availability of $context in custom content panes.

This request is being made

sdboyer's picture

This request is being made with increasing frequency, but unfortunately, the custom content block as it currently exists cannot have $context available, simply because it runs the contents of your custom text through the drupal filtering system, which means that even when 'php mode' is marked, the code is evaluated at a time & place where $context is not in scope.

A little while back, two or three people just happened to descend on me on IRC to ask me about this, so I did dish out a bit of code that ought to do the trick. It's still up on drupalbin: http://drupalbin.com/2032

Because that represents a non-trivial derogation from the way that the current custom content block works, however, the only way that code will make it into Panels is if another full-blown content type plugin is written to facilitate it; in the interest of backwards compatibility and not breaking peoples' sites, the custom content pane needs to stay as-is. I'll probably write up the whole custom content pane for RC1, but I'd certainly appreciate anyone helping out with it in the meantime...

BUT, with all that said, I'll tell you the same thing I tell everyone who asks about this: there comes a point at which you really would be better served by simply writing a custom content type plugin. IMO, that point is very clear - while the custom php code execution is handy for one-time uses & exceptions, the moment that you need to use a pane twice is the moment you should be writing a new plugin. If you stick with just using a custom code block in those cases, then you end up having to manually make changes to each and every instance of that code block whenever you want to make a change.

Also, you cut down on queries by writing custom plugins, which means that that a pane constructed from text will always execute faster than the same code written into a custom pane and being pulled from the db at runtime.

I agree 110%.

merlinofchaos's picture

BUT, with all that said, I'll tell you the same thing I tell everyone who asks about this: there comes a point at which you really would be better served by simply writing a custom content type plugin. IMO, that point is very clear - while the custom php code execution is handy for one-time uses & exceptions, the moment that you need to use a pane twice is the moment you should be writing a new plugin. If you stick with just using a custom code block in those cases, then you end up having to manually make changes to each and every instance of that code block whenever you want to make a change.

The only way I could agree more with this statement is if it said "And there should be ice cream at every meal."

Seriously, the custom content block is a convenience, but if you find yourself using it very much for PHP code, it's time to go put your stuff in a custom site module. It is not that much harder, it is much more maintainable, and it gives you greater access and control.

.

Michelle's picture

Unfortunately, the custom content type serves another purpose: people without a clue about PHP. I get a lot of "how do I add" requests on APK and I can usually rattle off a quick snippit for them to put in the custom content type. Most of the time it's UID based, which I can grab from the argument, but it would be handy to have the node context available as well.

So, while I agree that most people should simply write a content type in code, the UI version does serve a valuable purpose.

Michelle


See my Drupal articles and tutorials or come check out the Coulee Region

No doubt, Michelle, and

merlinofchaos's picture

No doubt, Michelle, and that's the client that it's aimed at. That kind of client isn't really capable of creating a module. And those clients arent' going to need to look at contexts, either.

I'm now straddling the two client types

lowVocal's picture

Right this minute I need to step beyond dropping code in a custom node and into contexts.

I want to replicate this panel-page http://dev.thevineyardvoice.com/world_voice for the video feeds I'm pulling and filtering with a taxonomy view. I have checked out my pal jerad's post on sony bmg http://drupal.org/node/241344. I remain confused, but undaunted. He and I will have to talk.

I'd love to pull the feedAPI mapped thumbs into one panel, a single taxonomy video feed into another and a taxonomy list view at the bottom. Changing only the display as I replicate the page....

I'll keep plugging - and one more person will soon behold the beauty of contexts.

Thanks for making it possible.

The UID is exactly what I'm

ulfk's picture

The UID is exactly what I'm looking for, I searched the issue queue but couldn't find the posts you referred to. Could you help me out at http://drupal.org/node/292734.

UPDATE - found it - http://drupal.org/node/292734

coming from a complete noob here ...

fluxline's picture

or am i missing something?

the question as i see it:
a context is set for a panel
an arg is passed into a panel
content panes within the panel use a relationship established by the context to display related information.

if a content pane does not make what is needed available, php in a custom content is where to go. (how i found my way here). but, there is no way to use the relationship to the node for such things as taxonomy or user. if limiting scope is the problem, what about making it available to mini-panels ?

I have a panel page
has node as a context
has term from node as a relationship
i have mini-panel embedded in panel above
has term as a context
takes term argument from panel.

ramble, ramble, ramble ... i just want to find a way to have access to the other objects in the relationship such as tid. i want to be able to do:

a view with taxonomy and other ckk integer values plus some viewcalc values (done)
a node content in 1 pane (done)
taxonomy for that node separated by vocabulary, 1 pane for each term (done)
along side, certain values from the view above. i only want to show a few of the values from the view, not all. (not been able to do)

i thought i would be able to use a custom content with some php to get the values i need, but i am unable to get the term id from the relationship to use.

any helpers might end up with a bowl of ice cream if i can arrange it ...

I guess the solution would be

Manuel Garcia's picture

To have a custom content type plugin that would have panel context arguments available to it.

Unfortunately im am a tourist when it comes to developing a module or things like that, i can get around php for theming and the like, but not to do something like this. Is there documentation on how to create a content type plugin for panels? Or perhaps you could point me to how to do it and i could write up a simple starting page for that porpuse on the documentation.

Thanks all for replying !

No news on this? lets

sethx's picture

No news on this? lets resurrect this post.. i believe there is lots of interest for this..

If nobody comes up with a solution we will have to custom develop this.. it may be OS'd or not, depends on $client .

contact me for more info in case you need something like this.

.

Michelle's picture

This functionality was added to Panels a while ago.

Michelle


See my Drupal articles and tutorials or come check out the Coulee Region

As Michelle said, this was

sdboyer's picture

As Michelle said, this was added in the RC release in mid-August.

And, let me just say again, that the custom content type plugin which allows access to context is inherently a hack, intended purely for temporary convenience. It is unwise to use it in any kind of situation where there is need for it to scale.

Clarify, please

astreib's picture

By "this" you mean the ability to reference $contexts in custom content?

Thanks,

Allan

Panels PHP

Panels

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week