Now that I'm tackling APK for D6, I'm back to working on the same stuff that got me writing the panels / fieldgroup integration to begin with. First off, it seems that the parameters have changed for the bit that prints the content. On line 24,

function fieldgroup_panels_render_fieldgroup($conf, $panel_args, $context) {

needs to become

function fieldgroup_panels_render_fieldgroup($subtype, $conf, $panel_args, $context) {

That gets the $node variable properly filled with the node context.

Then the next problem is that theme('fieldgroup_panel', $vars, $node->nid) is no longer valid because the theme system changed. I believe we either need a .tpl file for it, which is probably overkill, or to register the theme function. Registering it just means adding it to the existing function:

/**
 * Implementation of hook_theme().
 */
function fieldgroup_theme() {
  return array(
    'fieldgroup_simple' => array(
      'template' => 'fieldgroup',
      'arguments' => array('element' => NULL),
    ),
    'fieldgroup_fieldset' => array(
      'arguments' => array('element' => NULL),
    ),
    'fieldgroup_display_overview_form' => array(
      'arguments' => array('form' => NULL),
    ),
    'fieldgroup_panel' => array(
      'arguments' => array('vars' => NULL, 'nid' => NULL),
    ),
  );
}

In doing that, I realized "vars" is really a poor choice of names for that variable. I'm not sure what to call it, though. Any suggestions? Also, I think the smallest bit is a "pane" not a "panel" so fieldgroup_panel should probably be changed to fieldgroup_pane.

If you want, I can do this all up as a proper patch. I wanted to get your input first, though, to make sure I have everything how you want it so I don't need to reroll. I'm hoping this can get in soon as APK will depend on it working.

Thanks,

Michelle

CommentFileSizeAuthor
#3 fieldgroup.panels.txt3.98 KBmichelle

Comments

yched’s picture

We now have a content_view_field() function, that takes care of generating the output for a field.
So the if ($node) {...} part could become something like (untested) :

if ($node) {
  $groups = fieldgroup_groups($node->type);
  if (isset($groups[$conf['group']]) {
    $group = $groups[$conf['group']];
    $output = array();
    foreach ($group['fields'] as $field_name => $field) {
      $field = content_fields($field_name, $node->type);
      // possibly tweak the $field['display_settings']. See how content_panels_render_field() does it.
      $output[] = content_view_field($field, $node);
    }
    $block->subject = $group['label'];
    $block->content = $output ? theme('fieldgroup_panel', $output, $node->nid) : $conf['empty'];
    $block->delta = $node->nid;
  }
  else {
    // return an empty pane ?
  }
}

Which makes the code less coupled to the actual structure of the render array.

michelle’s picture

Thanks! I'll be working on this again later today and will give this code a whirl.

Michelle

michelle’s picture

StatusFileSize
new3.98 KB

Sorry this took so long to get back to. Here's the revised code, with your suggestion used and the rest cleaned up. It's working fine for me.

Still needs the addition to fieldgroup_theme() as noted in the first post.

(Change .txt to .inc)

If you're ok with this, can we get it in? We can always tweak it more later if needs be. What's currently in there is broken and this isn't so it's a step up, I think. ;)

Thanks,

Michelle

patchak’s picture

Tried this code on a test site that uses all the latest versions of cck (dev version) panels, (latest alpha 3 version).

I tried to insert existing fieldgroups in panels and it does not work I only get a message like this :

"d
Content fieldgroup content goes here."

I tried with existing and new fieldgroups. I inserted this file in the cck/modules/fieldgroup folder, is that the right place to insert it? I guess it is ...

After emptying the cache, creating new fieldgroups, new fields, new content type... can't get the old behaviour to go away on this one... does not seem to work at all from here. Is there any detail I missed? Maybe panels v. alpha3 changed something??

Patchak

michelle’s picture

@patchak - That text isn't even in this version. That's what it says in the original, broken version.

Michelle

patchak’s picture

I will have to re check all the versions I use.. Michelle could you post exactly on which version on cck and panels you got this to work so I can test again having the same versions as you do ? thanks

Patchak

michelle’s picture

I'm using the latest devs. But that's not the point. The text you posted is in the broken version currently in CCK which means you didn't replace it with the updated file. You aren't getting it to work because you're not using the code from this issue. You need to add to the theme function in the .module and replace the .inc file.

Michelle

patchak’s picture

Hummmm I did not get that I needed to add anything to the module file, sorry about that. I just replaced the actual .inc file. Will add that theme function and the report back here.

Thanks for your time,

Patchak

yareckon’s picture

patchak, I was also confused by the thread in to thinking this was in a dev version. I guess for this to be in the dev versions we would need somone to commit Michelle's patch to cvs. Which would be awesome of them, as this feature is broken!

michelle’s picture

Correct, the code needs to be committed before it will be in a dev version.

Michelle

yched’s picture

Status: Needs review » Fixed

Well, I would have liked to get at least a positive review from another person before committing, but it looks like this won't happen, and we can't really break something that's currently broken, so I went ahead. Committed. Thanks Michelle.

I'm still not a fan of theme_fieldgroup_panel(), BTW. No real suggestion, but I feel there should be a better way...

michelle’s picture

@yched: Yeah, as I said in #3, we can always tweak this more. The first step was getting it to _work_ at least so people can use it. I'd like to give the code a good going over and improve it but first I need to get this client work done and APK 1.0 out and having a working fieldgroup integration will help with both of those.

Thanks for committing it,

Michelle

wallbay1’s picture

Hey guys can someone please help me fix that problem
please give me a step by step instruction I am not a very wise coder actually i m not a coder at all :)

michelle’s picture

@wallbay1: What problem? This issue is fixed and I see no other comment by you on it.

Michelle

wallbay1’s picture

what I mean is
I am getting the "content goes here.."
am i suppose to use Dev version? I m confuse

wallbay1’s picture

Never mind Michelle,
I just had to put dev version of cck. everything works fine thanks for the help

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.