Hi!

Maybe this is really simple:

How do I check (with php) what content types which are used in a specific
group?
I have done an override of the group home page as explained here: http://drupal.org/node/214340#comment-706607

For example: If content type 'content_A' is activated in a group I would
like to print "Link to all content_A in this group" in the group home
page.

So, how can I make this statement?
if content_A is active in group_X {
Print 'something'
}

Thanks!
Seth

Comments

rconstantine’s picture

Well, I think there are a couple of things to think about here.

The short, quick answer is to simply do a database query to the tables this module owns as all of the data you want is there.

With that said, I'm pretty sure you can create Views to display a particular content type from a certain group using arguments in the URL. You could then use whatever script you are building to check which content types are available to the group and then dynamically create the links for the Views.

Good luck.

seth97’s picture

Hi!
I have already created the views for all Groups and all content types (i.e. URL:'node/$group/ContentTypeA').
Now I want to display a link to the view (on the group home page) if that specific Group is using that content type.

Don't know how to do this:

The short, quick answer is to simply do a database query to the tables this module owns as all of the data you want is there.

Could someone help me with this?

Thanks!
Seth

seth97’s picture

Status: Fixed » Active

This works, but maybe someone has something smarter?

I added this code in my override of the Group (node-group.tpl.php):

    $current_group = $node->nid;
    $path = dirname($_SERVER['PHP_SELF']);

    //Print link to 'Views' of content types that are active in the group

   //Check in the database
    $active_content_types = db_result(db_query("SELECT types_active FROM {og_content_type_admin} WHERE gid = %d", $current_group));

    if (empty($active_content_types)) { //If the group has the default settings
       $active_content_types = db_result(db_query("SELECT types_active FROM {og_content_type_admin} WHERE gid = %d", 0));
    }

    //content type 'image'
    $image_required = '"image";i:2';
    $image_allowed = '"image";i:1';
    if(strstr($active_content_types,$image_required) || strstr($active_content_types,$image_allowed)) {
    print '<a href="' .$path. '/node/' .$current_group. '/gallery">Image Gallery</a>';
    }

I search for the string '"image";i:X'
Where X can be: 0, 1 or 2
'i:0' not allowed by site admin or not activated by group manager
'i:1' allowed by site admin and activated by group manager
'i:2' required by site admin

If the content type 'image' is required or allowed in the current group I print a link to the view 'gallery'.

Thanks,
Seth

rconstantine’s picture

Status: Active » Fixed

Looks like you got it.

Anonymous’s picture

Status: Active » Closed (fixed)

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