Panels_mini allows you to use the great Panels UI to create blocks: you get presented a single panel (because it's meaningless to use multiple panels within a block, because blocks are too small in width by nature) to which you can add panes. It's as simple as that.

It also allows you to choose the style in which panes should be rendered: default (panes separated by whitespace), list (list of panes) or tabs (panes as tabs (depends on tabs.module)). This feature will probably (or at least hopefully) make it into Panels 2 as a "system-wide" ability.
I had to refactor the panels_render_display() function to achieve this. So I've included the proposed new version of it as a new function in panels_mini.module. I know this is unorthodox, but it's easier to review in this case, so IMO it's not off limits.

Known bugs:
1) rendering bug when using the "default" style: the divs overlap part of the content invisibly, they should stop where the region stops
2) rendering bug when using the "tabs" style: the tabs should tile below each other, up to the width of the region, and not overlap the content

ToDo:
1) ctrl+f/cmd+f through the files for "todo:" :P Most of these are related to things that should be changed when the panel style stuff has been moved into panels.module
2) the "block" layout should not be displayed to any panels_* module. It's specific to panels_mini. AFAIK, this is not yet possible with the current Panels API.
3) the "block" layout's icon should either be removed (see 2), or be updated, because now it's identical to the single column layout's icon.

Happy reviewing, Earl! :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

My initial review:

  • administer is typo'd as adminster in hook_perm.
  • The settings seem like they should be specific to panels_mini and not in layout_settings. I think this might lead to a pluggable system, but this should be set on the $display itself, I think. It doesn't seem like something we'd really want on a per-panel basis, as mixing these makes very little sense, IMO. But I can see something like $display->render_style = 'list', for example. That way it doesn't need to be specific to a given layout, which is really bad.
  • Since we've got panels_render_display and panels_render_panel we may also want to do panels_render_pane, perhaps.
  • Since we're talking about render_style, this means it might be possible to get all of the drag & drop rendering back into panels_render_display
  • panels_render_layout should probably basically go away and be merged into panels_render_display -- that means that theme($layout['theme'], ... ) can get the display as an argument. This could be valuable to complicated layouts. It could also be really valuable for theming purposes since administrators may want to be able to override specific displays.
  • theme_panels_mini_panel_tabs doesn't protect itself from the tabs module being disabled.
  • What does $panes_in_panel = array_intersect_key($display->content, array_flip($panes)); do? As near as I can tell this is the same as $panes except that it excludes items that aren't in $panels->content[]. The thing is, that shouldn't actually happen. Did you find that it was happening? If so, this is actually a bug.
Wim Leers’s picture

FileSize
7.23 KB

administer is typo'd as adminster in hook_perm.

Fixed.

The settings seem like they should be specific to panels_mini and not in layout_settings. I think this might lead to a pluggable system, but this should be set on the $display itself, I think. It doesn't seem like something we'd really want on a per-panel basis, as mixing these makes very little sense, IMO. But I can see something like $display->render_style = 'list', for example. That way it doesn't need to be specific to a given layout, which is really bad.

IMO, it does make sense to have it per-panel: suppose you have a panel page with two columns. In column 1, you have some panes that you always want to be displayed (thus "default" or "list"). And in column 2, tabs are used, because it's too much information to display below each other.
No changes made to this yet.

Since we've got panels_render_display and panels_render_panel we may also want to do panels_render_pane, perhaps.

What would be a use case for that? Isn't this something that can be done entirely using CSS?

Since we're talking about render_style, this means it might be possible to get all of the drag & drop rendering back into panels_render_display

Could you explain this please?

panels_render_layout should probably basically go away and be merged into panels_render_display -- that means that theme($layout['theme'], ... ) can get the display as an argument. This could be valuable to complicated layouts. It could also be really valuable for theming purposes since administrators may want to be able to override specific displays.

I agree. Implemented.

theme_panels_mini_panel_tabs doesn't protect itself from the tabs module being disabled.

Fixed.

What does $panes_in_panel = array_intersect_key($display->content, array_flip($panes)); do? As near as I can tell this is the same as $panes except that it excludes items that aren't in $panels->content[]. The thing is, that shouldn't actually happen. Did you find that it was happening? If so, this is actually a bug.

$panes is an array with the pane ids in the current panel
$display->content is an array of all panes in all panels, keyed by pane id
$panels_in_pane is $display->content, but with only the panes for the panel that's currently being rendered. It makes things easier in panels_mini_render_panel()

I could of course pass through $panes and then get the actual $pane object from the $display object in panels_mini_render_panel(), but I found that a bit ugly. If you disagree with this approach, I'll of course change it.

nedjo’s picture

Nice work! (I'm particularly looking forward to this being applied so I can deprecate the Panels Block module, which I cobbled together to achieve the same goal.)

I installed and did some basic testing and the module works just as expected.

I came across two issues:

1. There is an extra line in the INSERT INTO {panels_mini} statement's VALUES list (four columns inserted, the third is superfluous).

2. Uses array_intersect_key(), which was introduced in PHP 5. There are some backport examples at http://www.php.net/array_intersect_key and in PEAR at http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Function/array_inte....

I vaguely wondered if it would be useful to have the layout settings as a second page in the form wizard. As it is it's easy to overlook the options.

All in all this is looking very good.

amitaibu’s picture

Hi,
Looking forward for this module!
I've installed it, but I get an error
* Add a mini panel
* Give title name and click next:

user warning: Column count doesn't match value count at row 1 query: INSERT INTO panels_mini ( pid, did, title ) VALUES (4, 6, 'small ', '') in C:\wamp\www\drupal\includes\database.mysql.inc on line 172.

Wim Leers’s picture

@nedjo & Amitaibu: I had already fixed the SQL bug, but I forgot to put it here. Thanks for notifying me of that.

@nedjo: Thanks for the info about array_intersect_key(), I'll get that fixed too. And that may actually be the cause of the WSOD I'm getting on a server, of which I couldn't figure out the reason. Thanks!!

The next version of this module (already done actually, just have to fix that WSOD) includes support for a vertical and horizontal carousel display style, using the jCarousel module, that allows you to use the jQuery plugin with the same name. And it's fancy! :)

Wim Leers’s picture

FileSize
7.78 KB

And here's the next round.

changes:

general
- removed the "block" layout

panels.module
- new field in panels_display table: panel_settings, which is similar to layout_settings, but is used for storing the panel style (but allows for potentially more settings)
- updated the panels_save_display() function for compatibility with the previous, the load and delete counterparts are automatically compatible
- panels_render_display() now has a little brother: panels_render_panel() (this already existed in panels_mini)
- theme_panels_panel_$style() functions, for the various panel styles (this already existed in panels_mini)
- two new styles: horizontal carousel and vertical carousel (relies on http://drupal.org/project/jcarousel), sponsored by Paul Ektov of http://autobin.ru!

panels_common.inc
- new function: panels_common_get_layout_information($panel_implementation), this was previously hardcoded into panels_page.module, but since it's also necessary in panels_mini.module, I've put it in the .inc
- new function: function panels_common_panel_settings($display, $panels_implementation = ''), this was previously stored in block.inc as an implementation of layout settings. Other panels_*.modules can now easily offer panel styles as well.

css/panels_admin.css
- updated to not be panels_page specific
- the 2-column display (info container at the left side, layout container at the right side) is now compatible with Safari 2 (also tested in Firefox 2)

panels_page.module
- updated to use the panels_common_get_layout_information() function that was added to panels_common.inc

panels_mini.module
- removed the functions that are now moved to panels.module
- when a panel is deleted, the block is now deleted as well, and this is now also done correctly in hook_uninstall()
- updated to work with the panel_settings field in the panels_display table
- you can now choose any layout

That should give you a pretty good overview of the changes.

Since I do not have CVS write access, I could not create a patch that included the new files. So the new .zip contains the new files and a patch for the current panels.module.

dmitrig01’s picture

you don't need write access to make patches

Wim Leers’s picture

Could you point me to a how-to then? The how-to I found said that I should "cvs add" the new files and then create a patch.

Wim Leers’s picture

FileSize
27.69 KB

Yay for dmitrig01 in IRC!

Here's the .patch version of the above. This is much better.

amitaibu’s picture

Hi,
After understanding how to patch the file...
1. After defining the mini-panel, in the content tab, I'm unable to add content and I get an error:

* user warning: Unknown column 'panel_settings' in 'field list' query: INSERT INTO panels_display (did, layout, layout_settings, panel_settings) VALUES (13, 'onecol', '', 'a:1:{s:5:\"style\";s:4:\"tabs\";}') in C:\wamp\www\drupal\includes\database.mysql.inc on line 172.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\drupal\modules\panels\panels.module on line 259.

2. Minor imporvment - in the Panel style give a link to the Javascript and jcarousel - that's more user friendly I think :)

Wim Leers’s picture

You still have to run update.php then. The database schema has changed.

patchak’s picture

This looks like a really great module!
@Nedjo: I'm using the panels block module on a couple of sites, as you mentionned that you want to deprecate that module to use this one instead, do you think the transition from one to the other will be smooth or I'd have to recreate all my blocks and my panels??

Thanks,
Patchak

Wim Leers’s picture

Patchak, I'm afraid you'll have to recreate your panelsblocks (which extract data from existing panels, which are now called "panel pages") as mini panels. But because it's so much more straightforward, it shouldn't take too much time (unless you've configured your panels with a lot of custom parameters).

amitaibu’s picture

#11 Wim,
I've installed the module on a fresh installation (I've dropped the database and created a new one).
I still get this error:

user warning: Unknown column 'panel_settings' in 'field list' query: INSERT INTO panels_display (did, layout, layout_settings, panel_settings) VALUES (2, '', '', 'a:1:{s:5:\"style\";s:7:\"default\";}') in C:\wamp\www\drupal\includes\database.mysql.inc on line 172.

Did I miss something? - I might have, since I'm not a developer ;)

Wim Leers’s picture

FileSize
28.47 KB

I'm sorry, you're right. It seems I copied the wrong .install file to make the patch. Here's an updated version.

Wim Leers’s picture

FileSize
28.69 KB

And the patch I just posted was wrong too (a missing comma...). Here's the correct version.

amitaibu’s picture

works like a charm :)

Wim Leers’s picture

FileSize
28.69 KB

Now there are hooks to let modules provide new panel styles:

  • hook_panels_panel_style_info() (much like hook_widget_info in CCK), this returns an array of all panel styles that the module provides, along with some other information (label and for which panels implementations it can be used)
  • hook_panels_panel_style_settings(), this returns either a form with the settings or validates the settings chosen by the user
  • hook_panels_panel_style_render(), this returns the rendered HTML

This means that Panels now only provides 2 styles by default: "default" and "list".

I don't like the validation code. Currently, the panel style settings form is put in a fieldset inside the panel settings fieldset on the "general" edit form of a mini panel (or any other panels implementation).
Because the style settings form isn't a stand-alone form, I had to set the #validate property on the fieldset that contains the style settings. But element level validation functions only get $form, not $form_values. That's why I had to use global $form_values;, which is not nice, but it works.
Also because the style settings form is inside a fieldset in another form, you have to prefix your "name" parameter with panel_settings][style_settings][ in form_set_error() in the style settings validation function.
Unless we put the panel style settings in its own form, we won't be able to get rid of this.

Wim Leers’s picture

As soon as the 5.x-dev release of jCarousel has been updated by the packaging scripts (the release date should read August 11), you can use that to see an implementation of the Panels hooks. It also implements the style settings hook.

(I did not mention this in the previous follow-up, but the style settings hook is an optional hook!)

Wim Leers’s picture

FileSize
32.96 KB

Updated patch (one line changed, line 115 in the patch). The previous patch breaks the rendering of all other Panels implementations, it didn't set the default style when a module does not implement the optional Panels settings.

Wim Leers’s picture

FileSize
28.62 KB

Updates:

  • $display is listed as the first parameter wherever used
  • refactored hook_panels_panel_style_settings() into hook_panels_panel_style_settings_form() and hook_panels_panel_style_settings_validate(), this function receives both $form and $form_values. No more ugly code required now.
cpelham’s picture

This is wonderful. Can this be officially posted in the modules section yet? In the meantime I'm going to try to try it, once I study the process of applying patches a little more. I think 4 or 5 patches have been posted so far. Do I apply each one in succession or only the most recent one? Since there have been a number of patches now, could you just post a new version of the module with all the patches applied? If there's a lot going on with the code and we should just sit tight a little longer, that's fine. Thank so much for adding this extraordinary functionality to Drupal!

Wim Leers’s picture

Only the latest patch should be applied. See http://drupal.org/patch/apply.

cpelham’s picture

I applied the most recent patch (successfully I hope) and installed panels_mini. I activated it and just tried to create one. After selecting the kind of panel (I chose flexible), I get the following error on the next screen (which is trying to ask me to add content but it is not drawing the rows and columns):

warning: Invalid argument supplied for foreach() in /home/cpelham/public_html/drupal/modules/panels/panels.module on line 346.
user warning: Unknown column 'panel_settings' in 'field list' query: UPDATE panels_display SET layout = 'stories', layout_settings = '', panel_settings = '' WHERE did = 9 in /home/cpelham/public_html/drupal/includes/database.mysql.inc on line 172.

cpelham’s picture

I went back to patches 2&3 and found and applied panels.install update 1003 as you recommended and got rid of that error. I'm not sure why patch4 did not take care of that. maybe i applied it imcompletely...

But now I have another error and still the screen to add content to a newly created flexible mini panel does not draw correctly:
user warning: Duplicate entry '10' for key 1 query: INSERT INTO panels_display (did, layout, layout_settings, panel_settings) VALUES (10, 'flexible', '', 'a:1:{s:5:\"style\";s:7:\"default\";}') in /home/cpelham/public_html/drupal/includes/database.mysql.inc on line 172.

cpelham’s picture

I installed jCarousel, which fixed that problem.
Now...when I create a mini panel, choose what type of panel, and click next, instead of going to a panel layout settings tab that would allow me to choose how many columns and rows and set their widths (for a flexible panel), I go to edit tab (there are no other tabs drawn) where I can add content but am stuck with 3 throws. Should panel_mini have basically the same functionality, options and tabs as panel pages (or panel nodes)?

If this is also due to my poor reading and application of the patches and instructions above, forgive me.

joetsuihk’s picture

hello, FYI, I am the developer of tabbed_block module,
which is a module provide "tabbed" block
someone refer me to here, and i come see if i can help in providing "tabs view"

note that my module do not depend on tabs.module,
I develop a js for that.
please let me know if i can help.

Wim Leers’s picture

There were some CVS/patching problems so I had to move over all my changes manually to the latest Panels version. I forgot those that were made in panels.install, and this is causing your problems. I'll post an updated patch soon.

Wim Leers’s picture

FileSize
29.62 KB

Patch updated to include changes for panels.install.

merlinofchaos’s picture

Committed. I found two bugs with this that I fixed; I'm going to let this sit in -dev a bit before I roll a new alpha release, but probably only 'til the weekend or so.

cpelham’s picture

Thanks, I applied patch 5...

I have made a one-column panels page with two mini panels on it. Each mini panel is a flexible layout of one row with two columns, 65% and 35%. So far, so good. I just tried adding a third mini panel, this one a flexible layout of one row with THREE columns, 30% 40% and 30%. Unexpectedly, this third mini panel changed the above two column mini panels into three column mini panels. or at least it shrunk the first column in each from 65% down to 30%. It was my impression that each mini panel would be independent of the others. Is this not true or have I found a bug?

Here is what it is looking like, if i haven't explained it well:
http://www.crsny.org/drupal/en/frontpage-minipanels

Wim Leers’s picture

@merlinofchaos: what two bugs? I'm not sure what you mean.

@cpelham: each Mini Panel has an independent layout, the same as for Panel Pages. It's impossible that changing one Mini Panel's layout affects another's layout.
The page you linked to uses the Tabs Panel Style, but you've put the panes in different Panels inside a Mini Panel. If you want to use tabs, you should put multiple panes into the same Panel, to seen an effect.

amitaibu’s picture

Hi Wim,

I think that through a work around the Panels_mini can work as a node-decorator-panels. This is how I'm doing it with my non-developer skills.

create a panel for a specific content type:

1. Remove all the fields of the Node, so it will be blank (through the node-MY_Content.tpl.php)
2. Create panels_mini for the content type.
3. Enable the block in the content whenever the node of that content type appears.

This is two say two things:
1. It's possible to do such a thing :)
2. Maybe the node-decorator should use the Panel_mini to do what I did manually, but in a smarter way?

merlinofchaos’s picture

The two bugs I found:

1) in the edit layout page, it was loading a calling panels_page_load not panels_mini_load. I found this totally by accident because I realized that my original code (and thus your code that was following it) wasn't properly setting the title of the page; when I added that in, I noticed that the layout page didn't get a title set, and that was why.

2) Embedding panels within panels caused CSS ordering conflicts. I had to reorganize panels_render_layout a bit to compensate. This isn't really a bug with panels_mini exactly, but a difficulty of the system. I suspect we'll see more of these, too; already we've got cpelham's issue with flexible layout above, which may or may not be the same problem. (I suspect multiple flexible layouts on the same page may currently conflict with each other, but I'll have to doublecheck that).

amitaibu’s picture

Just as a remark to #33:

Remove all the fields of the Node, so it will be blank (through the node-MY_Content.tpl.php)

This probably not the best thing to do, since in the Panel it self user will probably want to show the nodes content along with other stuff.
That's it. I won't mess up the issue tracker any more about this :)

Wim Leers’s picture

@Amitaibu: Mini Panels itself isn't much code. It isn't complex either. The most complex part was the part where we allow Panels to have a style. It's now very easy to use that same functionality in *any* Panels implementation. It doesn't make sense to use a Panels implementation in another Panels implementation.
The purpose of Panels Node Decorator (perhaps a better name is "Node Panelizer"?) is -- as I understand it -- to allow the end-user to easily re-arrange the rendered output of a node. So it will make each field available as a pane.

@merlinofchaos:

1) Heh. I must admit that I didn't test this. Luckily it's a matter of replacing 4 letters :)

2) That's indeed a problem -- luckily it's outside the scope of this patch.

cpelham’s picture

Now I have made one mini panel with two rows, and inserted that mini panel into a row on a panel page. but still i do not have functioning tabs:

http://www.crsny.org/drupal/en/frontpagetabbed

Am I still not setting them up correctly?

Could I be having a problem because I upgraded to Javascript Tools module 5.x-0.8 ?

cpelham’s picture

Never mind, I finally figured it out!
Create mini panels and choose default (as opposed to tab).
Create a tab mini panel and place the default mini panels into rows in the tab mini panel.
Create a panel page and place the tab mini panel into a a row in the panel page.
The panel page now has functioning tabs, one tab for each default mini panel. Hurray!

Wim Leers’s picture

Status: Needs review » Fixed

Marking this as fixed, since it's committed. The first bug merlin found is fixed, the second is not really a panels_mini bug, rather a panels bug. I'll make a new issue for it.

Anonymous’s picture

Status: Fixed » Closed (fixed)
ahneill’s picture

Title: Panels_mini.module! » Note for final documentation

Comment #38 is REALLY critical for people to understand how to actually use a mini panel... I was having serious difficulty and am very used to panels... Just wanted to give my 2 cents about this should definitely get in the readme....

Create mini panels and choose default (as opposed to tab).
Create a tab mini panel and place the default mini panels into rows in the tab mini panel.
Create a panel page and place the tab mini panel into a a row in the panel page.
The panel page now has functioning tabs, one tab for each default mini panel. Hurray!

thanks everyone, this module is a big step forward

Wim Leers’s picture

Title: Note for final documentation » Panels_mini.module!

Don't change the title please.

Once we're in the beta phase, we'll start working on the documentation. Don't worry :)

bsuttis’s picture

I read at http://drupal.org/node/162185#comment-585113 that panels_mini will have an auto scrolling block feature -- from my limited look, I don't see any configuration options for it. Has this feature been dropped, or is it still on the todo list?

Update: Sorry, didn't realize that it's an additional module (http://drupal.org/project/panels_carousel) -- question answered. =|

najibx’s picture

How to get this working ....

First of all, I am not sure, which version is working. Could someone explain in more detail, as well as which version are confirmed working with each other. I tried mix and match various versions. Even the Comment #38 is not that clear to me.

I even got "white page" to enable the mini-tab block with :

drupal 5.5
jstools 5.x-1.x-dev (2007-Dec-06)
Panels 5.x-2.0-alpha14
Tabs Panel Style 5.x-1.2

Wim Leers’s picture

Don't spam this issue please. Ask in #drupal-support on IRC, post your question in the forum, or submit a new issue in the "support request" category.

fcortez’s picture

I'm using Drupal 5.9 and mini panels 5.x-2.0-rc1a. And all the mini panels display in the incorrect place. When I add the node to them it says they're correct. But display in other mini panel blocks any idea whats causing this? It was working and I've checked the database also and it has all the correct information? I'm at a lose???