get all fields of the group

23 views
Skip to first unread message

Hunk

unread,
Oct 2, 2009, 6:17:59 PM10/2/09
to Magic Fields
here this the function to obtain all the fields (with values) of a
group.

add this two function in get_custom.php http://gist.github.com/200146

this function verifies if the group is duplicated and if the fields
are duplicated

uses:

<?php
$all_data = get_group("name_group");

?>

this returns an adjustment with the information of the fields
http://gist.github.com/200192

in this example the group can be duplicated and contains the following
fields:
name: duplicate_field, field type: Textbox , duplicate: yes
name: single_field, field type: color picker, duplicate: no
name: picture, field_type: image, duplicate: no

this example the group was duplicated.

group 1 http://img.skitch.com/20091002-x5pwdr5n8118am3ur1t9idw3bw.jpg
group 2 http://img.skitch.com/20091002-tj4g9hyy7retpq3qskuh29q6bm.jpg

when it is a field type image has two values in the Array, [o] URL of
the original image and [t] URL of the thumbnail if it counts on
parameters (Max Height, Max Width or Custom).


DMG

unread,
Oct 2, 2009, 7:47:30 PM10/2/09
to Magic Fields
OMG!

Great work Hunk!

Although I personally don't have it working. (I did however use your
previous tips and modified the template .php files with tables to
hold the info.)
Where exactly does this "array" code go?

>
> this returns an adjustment with the information of the fieldshttp://gist.github.com/200192
>

And this maybe a dumb question but...

What is all the fuss about "DUPLICATING" fields and stuff? Why is it
useful? Once your fields are set to collect info that's it, right?

Sorry if that is a stupid one.

I am still hacking away here, but with progress.

Thanks!

JD

On Oct 2, 6:17 pm, Hunk <ing.ed...@gmail.com> wrote:
> here this the function to obtain all the fields (with values) of a
> group.
>
> add this two function in get_custom.phphttp://gist.github.com/200146
>
> this function verifies if the group is duplicated and if the fields
> are duplicated
>
> uses:
>
> <?php
> $all_data = get_group("name_group");
>
> ?>
>
> this returns an adjustment with the information of the fieldshttp://gist.github.com/200192
>
> in this example the group can be duplicated and contains the following
> fields:
>  name: duplicate_field, field type: Textbox , duplicate: yes
>  name: single_field,  field type: color picker, duplicate: no
>  name: picture, field_type: image, duplicate: no
>
> this example the group was duplicated.
>
> group 1http://img.skitch.com/20091002-x5pwdr5n8118am3ur1t9idw3bw.jpg
> group 2http://img.skitch.com/20091002-tj4g9hyy7retpq3qskuh29q6bm.jpg

Hunk

unread,
Oct 3, 2009, 2:08:11 AM10/3/09
to Magic Fields
the duplicated fields or groups can help much in the development

for example, we have a Write Panel called event, in this Write Panel
we have a field date that can be duplicated

when we created post with this write panel we have the possibility of
duplicating the field dates in case we want that the event has many
dates.

in the post 1 we can have 3 dates
in the post 2 we can have 1 date
in the post 3 we can have 5 dates

With this we do that a duplicated field could be n times in 1 post,
and we can add or remove duplicated fields

the duplicated groups work of of similar way.

for example we can have write panel called team, within this Write
Panel we created a called group member, in this group we can put its
field for the name, a field with its photo, a field with its
description, etc, etc.

when we created post, we can duplicate the group to add a member of
the equipment, the group will be duplicated with all the fields of the
group, and we can add or remove a duplicated group

DMG

unread,
Oct 3, 2009, 6:04:06 AM10/3/09
to Magic Fields
Thanks Hunk!

I guess I was just thinking my particular narrow usage.

Got it!

JD

em

unread,
Oct 10, 2009, 10:36:46 AM10/10/09
to Magic Fields
Thanks for posting this Hunk! This is exatly what I am after.
In fact, I am even creating a team_member group like your example :)
Unfortunately I am not great with php and can't really get this to
work properly.

I added the two functions to my get_custom.php and I implemented the <?
php $all_data = get_group("team_member"); ?> into my site where I want
the group to appear, but for some reason it won't display... I don't
really understand what I have missed. Is there something more I need?

Thanks in advance,

em


On Oct 2, 11:17 pm, Hunk <ing.ed...@gmail.com> wrote:
> here this the function to obtain all thefields(with values) of a
> group.
>
> add this two function in get_custom.phphttp://gist.github.com/200146
>
> this function verifies if the group is duplicated and if thefields
> are duplicated
>
> uses:
>
> <?php
> $all_data = get_group("name_group");
>
> ?>
>
> this returns an adjustment with the information of thefieldshttp://gist.github.com/200192
>
> in this example the group can be duplicated and contains the followingfields:
>  name: duplicate_field, field type: Textbox , duplicate: yes
>  name: single_field,  field type: color picker, duplicate: no
>  name: picture, field_type: image, duplicate: no
>
> this example the group was duplicated.
>
> group 1http://img.skitch.com/20091002-x5pwdr5n8118am3ur1t9idw3bw.jpg
> group 2http://img.skitch.com/20091002-tj4g9hyy7retpq3qskuh29q6bm.jpg

Hunk

unread,
Oct 11, 2009, 3:26:44 PM10/11/09
to Magic Fields
get_group return one array with all fields,

//show information of the array
<?php
print_r($all_data);
?>

em

unread,
Oct 13, 2009, 4:44:01 PM10/13/09
to Magic Fields
Thanks for your reply Hunk.

Somehow I still can't manage this working, just white space is
displayed. So I tried writing my own (very basic) code to get this to
show, here it is:

<?php
$total = getGroupDuplicates('team-name');
$people = 1;

while ($people <= $total) { ?>
<div class="team-member">
<p><?php echo get('team-name',$people); ?></p>
<p><?php echo get('team-email',$people); ?></p>
</div>
<?php
$people++;
} ?>
<?php endwhile; ?>

Now, this displays the first two team-members fine, then there is a
gap (in the size of a div) and then the team-members continue to
display as intended, but with the last member omitted completely.
For me this doesn't make any sense but I was hoping you might know.

I really appreciate your help, thank you!

emma

em

unread,
Oct 13, 2009, 4:44:15 PM10/13/09
to Magic Fields

Hunk

unread,
Oct 14, 2009, 1:12:05 AM10/14/09
to Magic Fields
try with this

<?php
$total = getGroupOrder('team-name');
foreach($total as $people){ ?>
<div class="team-member">
<p><?php echo get('team-name',$people); ?></p>
<p><?php echo get('team-email',$people); ?></p>
</div>
<?php } ?>

em

unread,
Oct 14, 2009, 3:46:35 PM10/14/09
to Magic Fields
You are the best, it's working perfectly!

Thank you so much, you are a star!

Hunk

unread,
Oct 15, 2009, 12:56:50 AM10/15/09
to Magic Fields
thanks :)

James

unread,
Oct 18, 2009, 1:34:35 PM10/18/09
to Magic Fields
Hi

I'm trying to achieve the same thing using the following code:


<?php
$total = getGroupOrder('Galleriffic');
foreach($total as $gID){ ?>
<ul>
<li><?php echo get('ImageTitle',$gID); ?></li>
<li><?php echo get('ImageDescription',$gID); ?
></li>
</ul>
<?php } ?>


But i get the following error:

Invalid argument supplied for foreach()


Any ideas what could be the issue?

Thanks

David

unread,
Oct 18, 2009, 2:50:23 PM10/18/09
to Magic Fields
The param in the "getGroupOrder" needs be the name of any field of
the group no the name of the group

And remember the getGroupOrder is case sensitive.

David.

James

unread,
Oct 18, 2009, 4:07:15 PM10/18/09
to Magic Fields
Hi David

That worked a treat, thanks.

Are there full instructions for this somewhere? as i couldn't find
anything about this before (blog or forum), just bits n pieces - i can
see it being popular with lots of other users.


Thanks again


James

David Valdez

unread,
Oct 18, 2009, 4:38:45 PM10/18/09
to magic-...@googlegroups.com
James.

Yes exists a big lack of documentation :( we are trying to fix this asap, but actually we need a bit of help on this. We are going to install a wiki for anyone can help.

David.

James

unread,
Oct 18, 2009, 4:50:17 PM10/18/09
to Magic Fields
Hi David

I'm a huge fan of open source projects and really admire that you've
gone on from flutter to continue with this project and make it better.
I'd be happy to help in anyway i can!

Thanks


James
Reply all
Reply to author
Forward
0 new messages