I needed to be able to use a group as a "content type" in Panels 2. Working with merlin, I was able to come up with some working code. The attached .inc file still needs to be cleaned up and changed over to be part of CCK, not part of panels. I intend to do this but I got behind schedule on what I need to do today and decided to post it as is to start.

Michelle

Comments

michelle’s picture

Status: Active » Needs review
StatusFileSize
new3.38 KB
new951 bytes

Ok, finally got this working. Thanks to the folks on IRC for helping me make a patch. :)

Michelle

michelle’s picture

StatusFileSize
new3.84 KB
new3.84 KB

Added empty text support to the .inc.

Michelle

yched’s picture

Status: Needs review » Fixed

I'm not too familiar with Panels 2 API right now, so i committed this (slighlty modified formatting and comments), so that this can get a larger audience. Thanks a lot Michelle.

My feeling is that the user-facing strings could be enhanced a little (the term 'CCK' is usually not displayed in the UI), but I didn't give a close look to the other existing strings, which we probably should be consistent with. This can be adjusted later on.

OK - this is only the beginning :-). Possible followups for anyone willing to pursue the effort :
- Expose a similar (panel) content type on the 'node edit form' side (i.e : display the 'node edit' widgets from a given fieldgroup in a panel)
- use the values of nodereference and userreference fields to expose additional node and user contexts.

The latter might lead us to structure Panels support in CCK in a way similar to how Views support currently exists : through field ops and hooks, so that specific field modules can expose specific stuff.

michelle’s picture

Thanks, yched.

I actually am looking at integrating cck and panels 2 on the editing side as well for advanced profile but this is much more complicated. If anyone else starts working on this, I'd love to hear so we can join forces. What I need to do goes beyond simply editing a CCK node in a panel but that's a big part of it.

Michelle

michelle’s picture

Status: Fixed » Active
StatusFileSize
new4.75 KB

I made a change to make it so you can have a .tpl.php file for each group. This allows you to theme the groups however you like. If you dont' have a .tpl file for it, it just outputs the fields as normal.

Michelle

GreenJelly’s picture

Please see [link deleted] for the files that are already modified.

michelle’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Wow, took me almost 2 months to get to this. Luckily CCK releases don't come often. ;)

I changed the code to simply make a theme function and leave the .tpl calling up to the theme. I also made it a proper patch against the latest code out of CVS. Hopefully this can be committed before the next CCK relase.

Thanks,

Michelle

dkruglyak’s picture

This looks like an important integration but I am not sure I understand why the issue was re-opened.

Should the new patch be applied against the latest in CVS? Could you clarify how this should be finalized / resolved and how to properly use the integration? Is there any documentation somewhere?

michelle’s picture

It was re-opened because I made a change to my original patch. My latest patch is against content_panels out of CVS from that day. For docmentation on applying patches, see http://drupal.org/patch

Michelle

dkruglyak’s picture

Thanks for clarifying. I am just starting with Panels 2 and was trying to figure out if this integration with CCK is documented somewhere.

michelle’s picture

Not that I know of. It's just something I needed for advanced profile. Not a lot to document... Just click "CCK Group" and pick your group.

Michelle

yched’s picture

Status: Needs review » Fixed

I slightly refactored the code and (at last) committed it. Thanks, and sorry for the delay.

BTW, you need to generate your patches against CVS, for instance using TortoiseCVS (I know you had a hard time with that ;-). Diffs against local copies of your files can't be easily applied by other people (or they have to make their own content_panels_orig.inc file). I had to manually apply the patch - no big deal for patches this size, but not really doable if you want to provide bigger patches.

michelle’s picture

I just followed the instructions here: http://drupal.org/patch/create . I don't use TortoiseCVS... Do I need to? I've asked several people on IRC how I should name the files since it says "diff -up original.php new.php > filename.patch" and I didn't know which file was supposed to get renamed, but no one seemed to know. I did base it on the latest file in CVS so I don't get what else I'm supposed to do. This is totally OT so feel free to catch me on IRC if you'd rather explain there. :)

Michelle

yched’s picture

Ah, right, the instructions in http://drupal.org/patch/create do mention 'simple' diff betwenn two local files (not against CVS).
Nevermind, then :-)

BTW, a typo sneaked in while I refactored your original patch (http://drupal.org/node/237312). Just fixed it in CVS. Sorry about that.

michelle’s picture

Status: Fixed » Active

As we discussed on IRC, your refactoring introduced a bug that causes the group's weight to be displayed along with the fields. I tracked down the problem and you were right; it wasn't the isset part. You removed if (is_array($value)) { and that's what caused it. The corrected code is here:

     $vars = array();
     if (is_array($node->content[$groupname])) {
       foreach ($node->content[$groupname] as $key => $value) {
         if (is_array($value)) {
           if (isset($value['#value'])) {
            $vars[$key] = $value['#value'] ;
           }
         }
       }
     }

I can do a patch if you want but I still am not clear on what the problem with the last patch was so I'm not sure it would be helpful.

Michelle

millions’s picture

Thanks Michelle,

you referred me here for the Weight problem. Where do I paste that code snippet?

michelle’s picture

If you want to patch it yourself, the code is in content_panels.inc. I was just marking issues in my queue as dupes of this because it is a cck bug, nothing to do with advprofile.

Michelle

millions’s picture

thank you! that worked great. I also went back to buddylist. Now the only thing is that somehow on my profile page, the settings ->content tab just goes to a blank page. all the other tabs work fine.

yched’s picture

Status: Active » Fixed

OK, I committed a more orthodox way of rendering child elements of the group.

I'm still not convinced that fieldgroups in content panes should provide greater themeability than fieldgroups in regular node views. In other words, i suggest we look into ways of using fieldgroups regular theming, or enrich it if needed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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