Contribution Date
Technology
Contribution Project
Contribution Details
I'm sorry for the late response here.
If you have built the pane, then there is a much easier way to do this. Otherwise, there is no straight-forward way to do this.
For plugins/panes you control, you can check for a 'restful_panels'
context in the render callback. For example, this is a 'render callback'
for my ctools content type plugin:
/**
* Callback to render a custom pane.
*/
function example_pane_render($subtype, $conf, $args, $contexts) {
if (!empty($contexts['restful_panels'])) {
return example_pane_json_render($subtype, $conf, $args, $contexts);
}
else {
// Just pass it on the admin info which is all we need to show if the node
// is viewed directly.
return example_pane_admin_info($subtype, $conf, $contexts);
}
}
The example_pane_json_render
just returns a stdClass
object. This structure is sent back as is from the RESTful endpoint. The example_pane_admin_info
generates HTML and is not really relevant in a RESTful call. It is only called if the panel is "viewed" normally.
For other types of panels, there are two ways I can think of:
- Handle this in your RESTful controller itself - parsing/massaging the data depending on your needs.
- Handle this in the structured panel renderer. This is much more work and I wouldn't recommend it, unless you can't reuse the parsing/massaging logic in your controllers easily.
Do you have any other ideas?
Contribution Issue Link
Contribution Link
Files count
0
Patches count
0