How do I print the multigroup in a block?
Here's how I print the value of one field:
$output = $object->field_name[0]['value'];
print $output;
How do I do a group? Thanks.
How do I print the multigroup in a block?
Here's how I print the value of one field:
$output = $object->field_name[0]['value'];
print $output;
How do I do a group? Thanks.
Comments
Comment #1
markus_petrux commentedYou can use the function fieldgroup_view_group(). See the doxygen in fieldgroup.module. You can find examples in:
- cck/modules/content_multigroup/panels/content_types/content_multigroup.inc (to render multigroups).
- cck/modules/fieldgroup/panels/content_types/content_fieldgroup.inc (to render standard field groups).
Comment #2
ManyNancy commentedHi thanks, can you please give me a little bit more specific instruction?
I have:
Which is not working.
I suspect that $group is not supposed to be a string? But looking at the example I still don't understand what format it's supposed to be in.
Thanks.
Comment #3
markus_petrux commented$group is an array. Please, check out examples in the files as described in #1.
Comment #4
ManyNancy commentedHi thanks, the example looks like this:
Looking at this, it puts all the groups into $group? I don't want all the groups, I just want one group.
Thanks.
Comment #5
markus_petrux commentedYou just need this part:
Comment #6
ManyNancy commentedOK, well now I have:
Is it supposed to be like this? This does not work, I don't see any output.
I just need one example, and hopefully I can figure out how to print the rest of my groups. Thanks.
Comment #7
markus_petrux commentedThe comments in the functions you're using often detail information about the arguments they take.
What do you have in $object? What does the function expect?
Comment #8
ManyNancy commentedHi, I don't know what an argument is.
I'm going to copy the function here so I have a reference:
One thing I don't understand is what this means:
It's a format I've never seen before. Does that mean I need to declare $group somewhere or something?
Thanks for all your help! I really appreciate it.
Comment #9
markus_petrux commented$object is supposed to contain a $node, yes. Though, I suggest asking in the development forums. Otherwise, you're issue may fall down the queue as many others. This issue is now far beyond CCK matters.
Comment #10
ManyNancy commentedI don't understand what you mean by beyond CCK matters, this issue is about displaying a cck fieldgroup? Since $object is $node, please let me know what I need to pass to the function so that it will do the correct things.
Nevermind anything I said about other modules since that's distracting. I'm just trying to render the fieldgroup inside a block. This should not be difficult since so many other modules have done it.
Thanks, and please please help.
Comment #11
stefan81 commentedHi, Markus
thanks for your patience and help!
Now I figured it out, Nancy:
Just replace $nodetype and $group_name with your values, then you get the fieldgroup.
In my case I printed the group using its name "group_edition" which is in a nodetype (content type) called "publication"
It is using the standard "fieldset" display format.
Now I wonder how I can display it as a "simple" styled fieldgroup.
Comment #12
stefan81 commentedHi again,
the code above worked inside page.tpl.php.
But not inside a block.
I get an error:
Fatal error: __clone method called on non-object in /mnt/sites/trilogo.de/web/beta02/includes/common.inc on line 1722
any clue what to do?
Comment #13
ManyNancy commentedI imagine you need to get the node object, since that's not part of a block? I'm not really sure. I did something like this:
$node_copy = drupal_clone(node_load(array('nid' => arg(1))));
Not that this works either. :( No fatal error but no multigroup displayed either. :(
Thanks for giving fresh insight yanku.
Comment #14
karens commentedTake a look at http://drupal.org/project/cck_blocks. A couple issues address putting a fieldgroup in a block, like #221182: Viewing CCK Groups as a block and #462924: Expose fieldgroup as block, so it is a feature request there and that is probably the best place for this.