Closed (fixed)
Project:
Panels
Version:
5.x-2.x-dev
Component:
API
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Jun 2008 at 13:35 UTC
Updated:
12 Jul 2008 at 19:50 UTC
Hi,
I'm fairly new to the world of Drupal. I have a module which generates a table currently displaying
in its own page e.g. http:..../CTSPServiceClassification. I'd like to display it in a pane in a panel.
I guess the panel is all about 'theming' content but at what level should I approach this problem.
Does my module have to call panel module api functions? Do I create, export & then somehow incorporate panel code into my module? Does my module have to generate 'block' content.
In short how do I place php generated HTML into a panel?
Comments
Comment #1
samsouk commentedthere's several options :
let's say you have a function mymodule_generate_table() :
1- add a "New custom content" pane to your panel, choose the PHP code input format, and call mymodule_generate_table() from there
2- create a block in your module, set $block['content']=mymodule_generate_table(), and add this new block to your panel
3- create a basic block in your module with $block['content'] set to anything (not empty), and do what you want in the template file block-mymodule-delta.tpl.php
the 3rd method, gives total control over visibility and theming, and avoids storing code into the database
you can set $block['myparam'] inside your module and use it as $block->myparams inside your template
you can set $block['content']='' inside your module to hide the block
Comment #2
gerbil230769 commentedThanks, sorry,
I was away for a while. Appreciate the feedback!
Comment #3
sdboyer commentedsouk's advice is a little misleading. You 'can' do all of those things, but none of them are going to provide you the greatest amount of flexibility.
I'd _strongly_ advise against #1. The custom content pane really isn't designed for anything systemic, it's designed for quick-fix, single-use hack jobs, basically.
#2 is a back way in to panels that will work, but again, with a pretty limited amount of flexibility. Of the three, it's the most advisable.
#3 essentially just dodges Panels entirely, and while you might want to use something like it eventually, it's really at the end of the line.
If you're looking to build something stable and flexible, then write a panels content type plugin. Now since you're new to drupal (and asking you to do that is a bit like asking you to jump in the deep, DEEP end of the pool), #2 might be your best bet for now. But with content type plugins, you've at least got a really detailed guide about all the different things you can do with it: http://doxy.samboyer.org/panels2/panels_api_plugins_content_types.html
Comment #4
sdboyer commented