Drupal - 每种有机组内容类型的单独菜单

发布于 2024-09-30 18:55:45 字数 281 浏览 2 评论 0原文

在我的网站上,我将两种内容类型设置为有机组节点。

  1. 体育组
  2. 教育组

网站上还有各种其他内容类型,设置为标准组帖子。允许用户将内容发布到组中,然后引用该组。

然后,我启用了“组详细信息”块以在每个组上显示,然后显示创建指向=标准组帖子的每个内容类型的内容链接。

我想做的,无论是使用该块完成还是我自己创建,都是限制某些内容类型创建链接到某些组。我不想允许在体育组中创建某些内容类型。我认为这可以通过自定义菜单或块来完成,但不确定所需的 PHP。

On my site I have set two Content Types as Organic Group nodes.

  1. Sports Group
  2. Education Group

There are also various other content types on the site, set to be standard group posts.To allows users to post content into groups, which then references that group.

I have then enabled the Group Details block to show on each group, which then shows create content links to each content types that = standard group post.

What I would like to do, whether its done with that block or I create my own is to limit certain content type creation links to certain groups. i.o.w I don't want to allow certain content types to be created in the Sports Group. I think this can be done with a custom menu or block, but unsure of the PHP required.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青萝楚歌 2024-10-07 18:55:45

找到了一种使用块创建手动菜单的方法。

请点击下面的链接,它解释了一切 - http://drupal.org/node/169126

下面是链接中的文本:


这是我从所有这些中汇总的内容...从组页面创建链接以创建自动分配给该组的内容...
下面的代码被放入一个格式设置为 php 的块中

<?php $group_title = og_get_group_context()->title; ?>
<h2>You are a member of the <?php print $group_title; ?> group </h2>
<?php $group_nid = og_get_group_context()->nid; ?>
<div class="user-input-link"><a href="http://your-site/node/add/your-content-type?gids[]=<?php print $group_nid; ?>">Post your own content-type into this group.</a>
</div>

并且它可以工作!

现在,您需要将其显示在组页面上,并且仅当用户是该组的成员时才显示。因此,在“显示块”部分中,您可以将其放入,它似乎可以工作:

<?php
  $in_og = FALSE;
if (module_exists('og')){
  $in_og = FALSE;
  $group_node = og_get_group_context();
  $gid02 = $group_node->nid;
  $gid = (int)$gid02;
  if ($gid02 == null) $gid = 0; 
  if (og_is_group_member($group_node)) $in_og = TRUE;
  if ($gid == 0) $in_og = FALSE;
}
return $in_og;

?>

Found a way to create manual menus by using blocks.

Follow the follwoing link which explains it all - http://drupal.org/node/169126

Below is the text from the link:


Here's what I put together from all of this.... To create links from a group page to create content that is automatically assigned to that group...
The code below was put into a block with formatting set to php

<?php $group_title = og_get_group_context()->title; ?>
<h2>You are a member of the <?php print $group_title; ?> group </h2>
<?php $group_nid = og_get_group_context()->nid; ?>
<div class="user-input-link"><a href="http://your-site/node/add/your-content-type?gids[]=<?php print $group_nid; ?>">Post your own content-type into this group.</a>
</div>

And it works!

Now you need to have it show up on group pages and only if the user is a member of that group. So in the "show block" section you can put this in and it seems to work:

<?php
  $in_og = FALSE;
if (module_exists('og')){
  $in_og = FALSE;
  $group_node = og_get_group_context();
  $gid02 = $group_node->nid;
  $gid = (int)$gid02;
  if ($gid02 == null) $gid = 0; 
  if (og_is_group_member($group_node)) $in_og = TRUE;
  if ($gid == 0) $in_og = FALSE;
}
return $in_og;

?>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文