I'm looking to output panes within panels as JSON as well, instead of HTML strings. Is there any general way to recursively output panes as JSON? Or can this only be done in an ad-hoc way (like with a overridden render_pane_content() function with custom code to handle each type of pane)?
Comments
Comment #2
hussainwebI'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:The
example_pane_json_renderjust returns astdClassobject. This structure is sent back as is from the RESTful endpoint. Theexample_pane_admin_infogenerates 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:
Do you have any other ideas?
Comment #3
colinmccabe commentedThanks for the advice! I agree, the general approach seems to be to write custom CTools content types. I was hoping for a silver bullet, but it doesn't look like there is one. Drupal wants to render everything itself, and to go against that requires custom code.
Comment #4
colinmccabe commented