{"id":14968621,"url":"https://github.com/district09/drupal_module_og-sm","last_synced_at":"2026-01-14T14:30:19.621Z","repository":{"id":54203614,"uuid":"102002607","full_name":"district09/drupal_module_og-sm","owner":"district09","description":"Organic groups site manager Drupal module","archived":false,"fork":false,"pushed_at":"2023-10-16T09:36:45.000Z","size":1150,"stargazers_count":0,"open_issues_count":5,"forks_count":2,"subscribers_count":10,"default_branch":"2.x","last_synced_at":"2023-10-17T02:05:41.622Z","etag":null,"topics":["d09check22","drupal","drupal-module","drupal7","drupal7-module","drupal8","drupal8-module","organic-groups","web"],"latest_commit_sha":null,"homepage":"https://www.drupal.org/project/og_sm","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/district09.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-31T13:17:50.000Z","updated_at":"2023-12-20T15:26:12.898Z","dependencies_parsed_at":"2023-10-16T18:50:02.668Z","dependency_job_id":"97629287-ed15-4f6c-a780-72eecf60135c","html_url":"https://github.com/district09/drupal_module_og-sm","commit_stats":null,"previous_names":[],"tags_count":9,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district09%2Fdrupal_module_og-sm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district09%2Fdrupal_module_og-sm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district09%2Fdrupal_module_og-sm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/district09%2Fdrupal_module_og-sm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/district09","download_url":"https://codeload.github.com/district09/drupal_module_og-sm/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239753700,"owners_count":19691160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d09check22","drupal","drupal-module","drupal7","drupal7-module","drupal8","drupal8-module","organic-groups","web"],"created_at":"2024-09-24T13:40:18.970Z","updated_at":"2026-01-14T14:30:19.555Z","avatar_url":"https://github.com/district09.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Organic Groups : Site Manager\n\nThis module provides support to setup a platform supporting multiple (sub)sites\nbased on [Organic Groups][link-og] (OG) functionality.\n\n* Define what node types should be used as Site's.\n* Simplified OG API by providing OG function wrappers.\n\n\u003e *NOTE* : Site entities are limited to node entities.\n\n## Functionality\n\nThis module and its submodules adds functionality to support:\n\n### Included in og_sm module\n\n* Support for Group types to become sites enabled (Site).\n* Support for Group Content types (Site Content).\n* Support for Group Users (Site Users).\n* Yml file discovery for site links.\n\n### Included in og_sm_admin_menu module\n\n* Site administration menu that replaces the default admin toolbar when the user\n  is in a Site context.\n\n### Included in og_sm_config module\n\n* Allow site specific configuration.\n* Allow overriding global config per site.\n\n### Included in og_sm_content module\n\n* Site content administration\n\n### Included in og_sm_context module\n\nOG context detection based on:\n\n* Path alias of the current page.\n* Paths starting with group/node/NID\n\n### Included in og_sm_menu module\n\n* Centralised functionality to provide Site specific menu items.\n\n### Included in og_sm_path module\n\n* Define a Site path prefix per Site.\n* Automatic path aliasing with the Site path as staring point.\n* Auto update of Site content aliases and Site related page aliases when the\n  Site path changes.\n* Altering the `group/node/nid/admin/...` paths to `[site-path]/admin/...`.\n\n### Included in og_sm_routing module\n\n* This module adds support to have Site specific routes.\n\n### Included in og_sm_taxonomy module\n\n* Support global vocabularies with Site specific terms.\n* Manage terms per Site.\n* Select only from terms within the Site when creating content.\n\n## Requirements\n\nMinimal system:\n\n* PHP 7.3 or higher.\n* Drupal 9.1.x or higher.\n\nThe Sites functionality is built upon [Organic Groups][link-og].\nFollowing modules are required to use the Sites functionality:\n\n* [Organic Groups][link-og]\n\n## Installation\n\nEnable the Organic Groups Site Manager module.\n\nEdit the node type settings of the types that should be Site types.\n\nEnable:\n\n* The Organic Groups \u003e Group checkbox\n* And the Site Manager \u003e Site Type checkbox.\n\n## API\n\n\u003e *NOTE* : In the following examples the og_sm services are accessed directly\n\u003e for sake of simplicity, however it is recommended to access these using\n\u003e [dependency injection][link-dependency-injection] whenever possible.\n\n### Load a Site node\n\nGet a Site node by its Node ID (nid). Will only return the node object if the\nnode exists and it is a Site node type.\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager'); \n$site = $siteManager-\u003eload($site_nid);\n```\n\n### Currently active Site\n\nA lot of code depends if we are currently in an active Site context.\n\nA helper method is available to get the currently active Site node.\nThis is a wrapper around the `OgContext::getGroup()` method + loading the node.\n\nGet the currently active Site node:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$site = $siteManager-\u003ecurrentSite();\n```\n\n### Clear all cache for Site\n\nClear all cache for one site.\n\nThis method does not clear the cache itself, it triggers the\n`SiteEvents::CACHE_CLEAR` event so modules can clear their\nspecific cached Site parts\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$site = $siteManager-\u003eclearSiteCache($site);\n```\n\n### Site types\n\nGet a list of node types that are Site node types:\n\n```php\n$siteTypeManager = \\Drupal::service('og_sm.site_type_manager');\n$site_types = $siteTypeManager-\u003egetSiteTypes();\n```\n\n### Check if node is a Site\n\nThe module provides helper methods to detect is a node or node type is a Site\nnode type:\n\nCheck if the given node is a Site type:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$isSite = $siteManager-\u003eisSite($node);\n```\n\n### Check if a node type is a Site type\n\nCheck if the given node type is a Site type:\n\n```php\n$siteTypeManager = \\Drupal::service('og_sm.site_type_manager');\n$isSiteType = $siteTypeManager-\u003eisSiteType($type);\n```\n\n### Get the path to the Site homepage\n\nGet the url to the homepage of a Site. This will return by default the path to\nthe detail page of the Site. Modules can implement\n`hook_og_sm_site_homepage_alter()` to alter the path.\n\nThe function will return the url instance based on the given Site or, if no Site\nis provided, the current Site (from OG context) will be used.\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$homepageUrl = $siteManager-\u003egetSiteHomePage($type);\n```\n\n### Site content types\n\nHelper method to get a list of site type objects that can be used to create\ncontent within a site.\n\n```php\n$siteTypeManager = \\Drupal::service('og_sm.site_type_manager');\n$siteContentTypes = $siteTypeManager-\u003egetContentTypes();\n```\n\n### Check if a content type can be used within a Site\n\nHelper method to check if a given content type can be used to create content\nwithin a Site.\n\n```php\n$siteTypeManager = \\Drupal::service('og_sm.site_type_manager');\n$isSiteContentType = $siteTypeManager-\u003eisSiteContentType($type);\n```\n\n### Check if content belongs to a Site\n\nHelper methods to get the Site (if any) of a given content item (node) belongs\nto.\n\nGet all the Site nodes a content entity belongs to.\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$sites = $siteManager-\u003egetSitesFromEntity($entity);\n```\n\nGet the Site node object from a given site content entity object.\nIf a entity belongs to multiple Sites only the first Site will be returned.\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$site = $siteManager-\u003egetSiteFromEntity($entitiy);\n```\n\nCheck if the given entity belongs to a Site:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$isSiteContent = $siteManager-\u003eisSiteContent($entitiy);\n```\n\nCheck if the given entity belongs to a given Site:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$isMember = $siteManager-\u003econtentBelongsToSite($entitiy, $site);\n```\n\n### Check if user is member of a Site\n\nHelper methods about the Sites a user is member of.\n\nGet the Site nodes a given user belongs to:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$sites = $siteManager-\u003egetUserSites($account);\n```\n\nCheck if a user is member of the given site:\n\n```php\n$siteManager = \\Drupal::service('og_sm.site_manager');\n$isMember = $siteManager-\u003euserIsMemberOfSite($account, $site);\n```\n\n### module_name.site_links.menu.yml\n\nThe naming of the .yml file should be `module_name.site_links.menu.yml`\n\nThe allowed parameters per menu item are the same as core's `module_name.links.menu.yml`\nfile. Dynamic route parameters like the group's entity type (`{entity_type_id}`)\nand the site node (`{node}`) are automatically injected when needed.\n\nExample:\n\n```yml\nog_sm.site.admin:\n  title: 'Administer site'\n  route_name: entity.node.og_admin_routes\n  menu_name: og_sm_admin_menu\nog_sm.site.structure:\n  title: 'Structure'\n  route_name: og_sm.site.structure\n  parent: og_sm.site.admin\n  menu_name: og_sm_admin_menu\n  weight: 30\n  options:\n    attributes:\n      class:\n        - 'toolbar-icon-system-admin-structure'\n```\n\n### hook_og_sm_site_menu_links_discovered_alter(\u0026$items)\n\nAlter the menu items as gathered using `module_name.site_links.menu.yml`.\n\n## Events\n\nThe og_sm module triggers multiple events to make it easier to alter\nfunctionality when a Site is involved.\n\n### Clear all Site cache\n\nWhen `SiteManager::clearSiteCache()` is called, it will not clear any cache\nitself. It will trigger the  `SiteEvents::CACHE_CLEAR` event\nso modules can clear the Site parts they have cached.\n\n* `SiteEvents::CACHE_CLEAR` : Cache clear method is called for the given Site.\n\n### Site node type action events\n\nThe module triggers events when a node type is being added or removed as being a\nSite node type.\n\n* `SiteTypeEvents::ADD` : Site node type is being added as a Site type.\n* `SiteTypeEvents::REMOVE` : Site node type is no longer a Site type.\n\n### Site action events\n\nThe module watches actions taken place on Site nodes and triggers its own events\nwhen an action happens:\n\n* `SiteEvents::PRESAVE` : Site node being prepared to be inserted or\n  updated in the database.\n* `SiteEvents::INSERT`  : Site node being inserted.\n* `SiteEvents::UPDATE`  : Site node being updated.\n* `SiteEvents::SAVE`  : Act on a Site node being saved. Will be\n  triggered after a node is inserted or updated. It will always be called after\n  all the `SiteEvents::INSERT`/`SiteEvents::UPDATE` events listeners are processed.\n* `SiteEvents::DELETE`  : Site node being deleted.\n\nThere are also special post-action events available: the default action hooks\n(insert, update, save and delete) are called during a DB transaction. This means\nthat it is not possible to perform actions based data in the database as all SQL\noperations are not committed yet.\n\nTo allow modules to interact with a Site node actions after the Site node \u0026 all\nqueries by implemented events are stored in the database, following extra action\nevents are triggered:\n\n* `SiteEvents::POST_INSERT` : Site node is inserted in the DB and all\n  `SiteEvents::INSERT` event listeners are processed.\n* `SiteEvents::POST_UPDATE` : Site node is updated in the DB and all\n  `SiteEvents::UPDATE` event listeners are processed.\n* `SiteEvents::POST_SAVE` : Site is inserted or updated in the DB and all\n  `SiteEvents::INSERT`, `SiteEvents::UPDATE`, and `SiteEvents::SAVE` event\n  listeners are processed.\n* `SiteEvents::POST_DELETE` : Site is deleted from DB and all\n  `SiteEvents::DELETE` event listeners are processed.\n\n## Hooks\n\nThe og_sm module also provides multiple hooks to make it easier to alter\nfunctionality when a Site is involved.\n\n\u003e The hooks can be put in the `yourmodule.module` OR in the\n\u003e `yourmodule.og_sm.inc` file.\n\u003e The recommended place is in the yourmodule.og_sm.inc file as it keeps your\n\u003e .module file cleaner and makes the platform load less code by default.\n\n### The site node is viewed\n\nWill only be triggered when the node_view hook is triggered for a node type that\nis a Site type.\n\n```php\n/**\n * Implements hook_og_sm_site_view().\n *\n * @param \u0026$build\n *   A renderable array representing the entity content. The module may add\n *   elements to $build prior to rendering. The structure of $build is a\n *   renderable array as expected by drupal_render().\n * @param \\Drupal\\node\\NodeInterface $site\n *   The site node.\n * @param \\Drupal\\Core\\Entity\\Display\\EntityViewDisplayInterface $display\n *   The entity view display holding the display options configured for the\n *   entity components.\n * @param $view_mode\n *   The view mode the entity is rendered in.\n *\n * @see hook_node_view()\n */\nfunction hook_og_sm_site_view(\n  array \u0026$build, \n  \\Drupal\\node\\NodeInterface $site, \n  \\Drupal\\Core\\Entity\\Display\\EntityViewDisplayInterface $display, \n  $view_mode\n) {\n  // ...\n}\n```\n\n### Alter the Site homepage path\n\nThe `SiteManager::getSiteHomePage()` method creates and returns the url instance\nto the frontpage (homepage) of a Site. That homepage is by default the Site node\ndetail page (node/[site-nid]).\n\nImplementations can require that the homepage links to a different page (eg.\ngroup/node/NID/dashboard).\n\nThis alter function allows modules to alter that path.\n\n```php\n/**\n * Implements hook_og_sm_site_homepage_alter().\n *\n * @param \\Drupal\\node\\NodeInterface $site\n *   The entity object.\n * @param string $route_name\n *   The route name.\n * @param array $route_parameters\n *   The route parameters.\n */\nfunction hook_og_sm_site_homepage_alter(\n  \\Drupal\\node\\NodeInterface $site, \n  \u0026$route_name, \n  array \u0026$route_parameters\n) {\n  $route_name = 'og_sm.site.dashboard';\n}\n```\n\n[link-og]: https://www.drupal.org/project/og\n[link-dependency-injection]: https://www.drupal.org/docs/8/api/services-and-dependency-injection/services-and-dependency-injection-in-drupal-8\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistrict09%2Fdrupal_module_og-sm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistrict09%2Fdrupal_module_og-sm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistrict09%2Fdrupal_module_og-sm/lists"}