For instance, I have a cck text checkbox that makes a post into a blog.

I want to be able to use a certain panel on it if the checkbox is checked, and not if it is unchecked.

Thanks!

Comments

merlinofchaos’s picture

That would be awesome. This is not a 5 minute task, and is going to require a wider of view how to set up so that it's configurable without being an absolutely insane UI. In a way this stands to be as theoretically complex as Views filters.

In the short run, I think we need a PHP code access plugin. It's also plausible for people to write their own customized access plugins. This one in particular would make a good tutorial.

Flying Drupalist’s picture

Thank you, when I was first thinking about this I thought it was fully possible and imagined in my head views filters. It was only later when I actually tried to do it that I realized it was only in views and not panels.

Yeah I would love a PHP code access plugin short term solution.

Thanks a lot!

merlinofchaos’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 6.x-3.x-dev » 6.x-1.x-dev

THis is properly a chaos tools feature. Maybe Markus would like to take a look at this sometime?

merlinofchaos’s picture

There is now a PHP Code access plugin.

Flying Drupalist’s picture

Thanks a lot, can you give an example for how to check if a field has value?

markus_petrux’s picture

I'll take a look at this as well to see if I can help in one way or another.

markus_petrux’s picture

hmm... so if we have a PHP Code access plugin that has access to all contexts, then maybe all we need is a few sample snippets somewhere that help figure out how to deal with CCK Fields?

This is basically because creating an access plugin for CCK Fields may require a lot of stuff. For example, how do we build the settings form for fields of type foo or bar. I'm thinking this would require something on the line of filter handlers in views, where we have a basic form that can be overriden by other fields. I think it is not possible to provide a form that allows to customize filters for any CCK Field in the world. This would have to be implemented by the fields themselves, and they also do this for views... so do we really want to duplicate this stuff here?

merlinofchaos’s picture

I think you're right, Markus. Creating a few snippets and putting them into the documentation is a good way to go. I'm working on a structure for the advanced help right now, so that in the -rc there will be some placeholders and links to issues.

blup’s picture

subscribing

Flying Drupalist’s picture

Hi guys, has this already been implemented?

autopoietic’s picture

subscribing

itangalo’s picture

Subscribing!

Also, here's a snippet that checks a CCK value for a node in the regular node template panel:

// Uncomment to view the data available in condition checks – requires Devel installed
// dpm($contexts);

$loaded_node = node_load($contexts['argument_nid_1']->argument);
$field_value = $main_tag->field_name_here[0]['value'];

return ($field_value == 'your condition here');

The two first lines could be put directly into the return statement, which would give you a bit more speed and a lot less readability.

Cheers,

nevets’s picture

I would guess that

$loaded_node = node_load($contexts['argument_nid_1']->argument);
$field_value = $main_tag->field_name_here[0]['value'];

should be

$loaded_node = node_load($contexts['argument_nid_1']->argument);
$field_value = $loaded_node->field_name_here[0]['value'];

If not, why load the node and where does $main_tag come from?

merlinofchaos’s picture

Status: Active » Closed (duplicate)

Let's combine these two issues: #618214: context_field access plugin -- marking this one dup as that one has a plugin that probably needs more refinement.

ayalon’s picture

Status: Closed (duplicate) » Active

The example above does not work with cck fields.

There is still no selection rule for CCK fields. I'm not sure if a node_load() is a performance issue before the page has been selected.

itangalo’s picture

Status: Active » Closed (duplicate)

@nevets: You're absolutely right. Thanks for spotting this (and sorry for my miss when changing variable names).

@ayalon: This issue is now persued at http://drupal.org/node/618214, so I'm marking this as a duplicate again.
If you want to discuss the particular snippet, it is probably better to do it at http://groups.drupal.org/panels.

I'm posting the snippet again, for clarity. (Note that you have to change "argument_nid_1", "field_name_here" and "'your condition here'" in order to get it working. Uncommenting the dpm line will help in finding new values.)

// Uncomment to view the data available in condition checks – requires Devel installed
// dpm($contexts);

$loaded_node = node_load($contexts['argument_nid_1']->argument);
$field_value = $loaded_node->field_name_here[0]['value'];

return ($field_value == 'your condition here');