Project:Organic Groups Sites
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi,

Could an example be given on what steps need to be taken to share custom content types across the sites?
I copied node.inc and tried to modify it to the needs of my custom content type, but it doesn't work as expected.
The basic node gets shared (title and body), but whatever i try, i can't get the custom fields to be shown on the subsite.

Should i only change the 3 hooks supplied by node.inc, or also the other methods?
How exactly should i go about using the form_alter hook? It's not very clear how i can add custom fields to this.

Thanks in advance!

Comments

#1

Found the following link useful

http://learn.awakenedvoice.com/2007/07/30/drupal-cck-and-views-tutorial/

Check there Out
Praveen Kumar Veeramalla

#2

Under modules/og_sites/og_sites/module open up node.inc, there is a function called node_og_sites_shared_tables which defines an array. Simply add the table names that your CCK fields use to hold their data and og_sites will figure it out for you. Here is an example of what I use...

function node_og_sites_shared_tables() {
  return array(
    'node',
    'node_revisions',
    'node_field',
    'node_field_instance',
    'audio',
    'audio_file',
    'audio_itunes_item',
    'audio_itunes_channel',
    'audio_image',
    'audio_metadata',
    'content_field_address',
    'content_field_education',
    'content_field_email',
    'content_field_link',
    'content_field_main_image',
    'content_field_name',
    'content_field_organization',
    'content_field_phone_number',
    'content_type_audio',
    'content_type_blog',
    'content_type_businesscard',
    'content_type_cartoon',
    'content_type_ed_classified',
    'content_type_event',
    'content_type_forum',
    'content_type_image',
    'content_type_job',
    'content_type_link',
    'content_type_news',
    'content_type_page',
    'content_type_poll',
    'content_type_resume',
    'content_type_story',
    'content_type_uprofile',
    'content_type_usernode',
    'edi_classified_nodes',
    'event',
    'event_repeat',
    'event_repeat_nodes',
    'trackback_node',
    'trackback_received',
    'trackback_sent',
    'comments',
  );
}

The content_type_* tables are the tables that hold my custom CCK field values, the rest are various tables used by modules that affect a node. Any time a node is submitted and saves to any of these tables, the data will be carried over to the hub tables instead. Also note that I did not prefix the tables the sites prefix as they are in the database.

John

#3

@jshuell, thanks for posting this useful tip and sample code.

To avoid patching the existing file, you could write a new file named for an enabled module, e.g., content.inc, and naming the function content_og_sites_shared_tables().

I'd be interested in a way to provide a UI for this. E.g., on a CCK content type's settings page, a checkbox to share this content type. Then content_og_sites_shared_tables() returns the appropriate tables based on which content types are selected for sharing.

nobody click here