I want to display a fieldgroup from a node (of type Vendor) referenced from another node (of type Product) outside its template (i.e. inside the template of Product, not Vendor). I want to know how to force the [#children] to be created.

I've recently learnt how to force the creation of the ['view'] for content:

//http://drupalcontrib.org/api/function/content_fields/6
        $field = content_fields($field_name,$content_type_name);

 //http://drupalcontrib.org/api/function/content_view_field/6
         $output = content_view_field($field,$node);

I'm looking for an equivalent for a fieldgroup.

grateful for feedback,

Webel

Comments

markus_petrux’s picture

Version: 6.x-2.1 » 6.x-2.x-dev
Status: Active » Fixed

If you know how to use content_view_field(), then you know how to use fieldgroup_view_group().

a) Get the latest development snapshot of CCK for Drupal 6.
b) Open cck/modules/fieldgroup/fieldgroup.module and look for functions:
--- fieldgroup_build_content(): Build the node content element needed to render a fieldgroup.
--- fieldgroup_view_group(): Render a single field group, fully themed with label.

An example that uses fieldgroup_view_group() can be found in cck/modules/fieldgroup/panels/content_types/content_fieldgroup.inc, function fieldgroup_content_fieldgroup_content_type_render().

markus_petrux’s picture

Title: How force population of ['#children'] outside template, and how then directly access the formatted rendered output » How to render a single field group?

Better title...

webel’s picture

@markus_petrux Thanks for detailed feedback, I'll try it and report back here. BTW I did look for such under http://drupalcontrib.org/api/file/contributions/cck/modules/fieldgroup/f... but those methods aren't listed there.

webel’s picture

Ok, this worked for me after installing cck-6.x-2.x-dev, many thanks, Webel

yched’s picture

Just a note for markus: would it be possible to commit the new fieldgroup_view_group() to HEAD ?
Don't bother making it actually *work*, fieldgroup.module is by far not fully ported to D7 and I'd be utterly surprised if it produced anything else than a bunch of fatal errors right now. It's just so that we don't lose track of D6 evolutions.
Thanks !

markus_petrux’s picture

@yched: Sure, the patches were here: #495582: Panels integration for multigroups

I'll checkout HEAD, apply the relevant changes there, and update that issue. I won't be able to test it against D7 though. Just the commit.

yched’s picture

Sure, you won't be able to test anything anyway ;-). Thanks !

markus_petrux’s picture

Status: Fixed » Closed (fixed)

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

taote’s picture

Status: Closed (fixed) » Active

This works great. I'm using it combined with Views and Custom Fields to get a read only view of the node, but is there a way to render the group with including the empty fields?

Thanks.