Posted by shushu on June 1, 2014 at 6:47am
Hi all,
I post on my blog about my experience with OG API.
When a requirement of adding a field to any group in the site, the power of the API shows its strength.
This is how to do it.
Like always, comments are welcome, and I hope it will be useful for anyone.
http://blog.mobile4social.com/content/organic-groups-api-nicely-built-ar...
Regards,
Shushu

Comments
OG developer information
Thanks for the blog entry, it gave a really clear explanation of how you introduced the field to taxonomy terms using the og API.
I am on the learning curve for developers and one of my (advanced) goals is to understand more about og. From the basic configuration information under projects/og which provides advice only through the UI it is not clear what the Boolean field you added would actually give you in an og context. All you are advised to do is to add the group content (list) field to content pages to reference the group(s) which use the content
Can ask how you developed your current understanding of the API. Apart from og.api.php (which is great for function definitions but light on context) I can't find much information on using it for development to provide a guide to further study.
Thanks
Update to my previous post
Ok, for anybody else who want to get to know the OG API better I recommend reading the og.test file in the og directory. You get a lot of examples of calling the OG functions within custom modules such as those covered in this post.
Got to say I still don't understand WHY Shushu needed to introduce a new OG field to solve his problem in OpenScholar .... in other words I don't understand the problem with just adding a field to the basic definition of terms in taxonomy for his site and what making it an OG group_content field changes. So if anyone can see the problem and how it is solved and help me out with an explanation I would appreciate it.
Thanks
Hi Simon, First, like
Hi Simon,
First, like everything in software development, surely there are several ways to do the same task, so you might be correct.
I am not sure what you mean in "add a field to the basic definition of terms". Is it possible to add a field once, and that it will be added to any vocabulary term ? AFAIK, each vocabulary is considered a bundle, so you should add it to each vocabulary once you create it.
Back to my post, I will try to explain why I wanted another field. The requirement was to allow group owners to decide whether when someone view a term page, the term description will be seen or not. Since it is a per-term configuration, it better be a field-per-term.
Once we have this boolean field per term, we were able to use it in the taxonomy-term.tpl.php file, and decide according to the field value whether to show the description or not. Other use cases for this behavior, for example, is adding a geofield per term, in order to show terms on a map, and so on.
Hope this clarifies the issue.
Regards,
Shushu