在 Drupal 7 中预填充 group_audience 字段(有机组)

发布于 2024-12-24 03:20:20 字数 307 浏览 3 评论 0原文

我试图让 prepopulate 模块与 og 一起使用,但收效甚微。据我所知,我可以做 ?edit[group_audience]=123 ,通过查看代码,似乎 prepopulate 插件做了它应该做的事情,并设置了将 #value 下拉至 123,但由于某种原因,这根本不起作用。

我还发现一些信息说可以使用 ?gids[]=123 预填充字段,有没有人成功完成此操作,或者有真正正确的解决方案?

I'm trying to get the prepopulate module to work with og with little success. From what I understand I can do ?edit[group_audience]=123, and by going through the code it seems the prepopulate plugin does what it is supposed to, and sets the dropdown #value to 123, but for some reason this doesn't work at all.

I've also found some information saying that it is possible to prepopulate the field using ?gids[]=123, has anyone had success with this, or has a real proper solution?

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

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

发布评论

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

评论(5

黎歌 2024-12-31 03:20:20

所以...对于 D 7.22 和 OG 7.x-2.1 执行此操作的正确方法是:

node/add/[content-type-machine-name]?og_group_ref=[group-id]&destination=node/[group-id]

上述答案不适用于我的设置。

看看我是如何在这里浪费周日的:Drupal有机群体预填充受众领域

So... the right way to do this for D 7.22 and OG 7.x-2.1 is:

node/add/[content-type-machine-name]?og_group_ref=[group-id]&destination=node/[group-id]

The above answers did not work for my setup.

See how I wasted my Sunday on this here: Drupal Organic Groups Pre-populated Audience Field

玩物 2024-12-31 03:20:20

您是否尝试过 ?edit[group_audience][]=123

群组受众是一个多选框,因此您可能需要使用允许设置多个值的语法。
?编辑[group_audience][]=123&编辑[group_audience][]=42&编辑[group_audience][]=1

Did you try ?edit[group_audience][]=123 ?

Group audience is a multiselect box so it is possible that you need to use this syntax that allow to set multiple values.
?edit[group_audience][]=123&edit[group_audience][]=42&edit[group_audience][]=1

风吹短裙飘 2024-12-31 03:20:20

不需要预填充模块:

?gids_group[]=123

在 Organic Groups 自述文件中找到此内容:

您可以制作自己的 URL,从而产生有用的行为。

例如,

node/add/group-content?gids_node[]=4 

将在节点表单中添加一个选择节点ID为4的组。

前缀实体可以更改以指示其他实体
允许制作 URL 的类型,并且可以有多个变量,
例如,

node/add/group-content?gids_node[]=4&gids_user[]=3&gids_group[]=5,6,7

上面的 URL 将选择节点 ID 为 4 的组,以及用户 ID 为的组
3、以及具有唯一组ID 5、6和7的组。
请注意,组 ID 5、6 和 7 的实际实体可以是任何实体(例如
节点或用户)。

Don't need the prepopulate module:

?gids_group[]=123

Found this in the Organic Groups readme:

You may craft your own URLs which produce useful behavior.

For example,

node/add/group-content?gids_node[]=4 

will add a select the group with node ID 4, in the node form.

The prefixed entity can change to indicate other entity
types allowing crafting the URL and you can have multiple variables,
for example,

node/add/group-content?gids_node[]=4&gids_user[]=3&gids_group[]=5,6,7

The above URL will select the group with node ID 4, and the group with user ID
3, and the groups with the unique group ID 5, 6 and 7.
Note that the actual entity of group ID 5, 6 and 7 can be any entity (e.g.
nodes or users).

沫尐诺 2024-12-31 03:20:20

通过将 ?gids[]= 附加到您的节点/添加 URL,您可以指定组受众。通过输入以逗号分隔的 nid 列表,您可以指定多个受众。

By appending ?gids[]= to your node/add URL, you can specify the group audience. By throwing in a comma-delimited list of nids, you can specify multiple audiences.

若无相欠,怎会相见 2024-12-31 03:20:20

对于 Drupal 7,使用 og 7.x-2.1,您需要安装实体引用预填充模块(并按照其自述文件中的说明进行操作)。一旦你做到了这一点,剩下的事情就会像魔术一样发挥作用。如果没有安装/启用该模块,当您尝试执行以下操作时,不会发生任何事情。此 url 实现了使用 id 1135 的组预填充 og_group_ref 字段的预期结果:
http://[site]/node/add/group-post?og_group_ref=1135

For Drupal 7, with og 7.x-2.1, you need to have the entity reference prepopulate module installed (and follow the instructions in its readme). Once you do that, then the rest works like magic. Without that module installed/enabled, nothing happens when you try to do what is below. This url achieves the desired result of pre-poulating og_group_ref field with the group with id 1135:
http://[site]/node/add/group-post?og_group_ref=1135

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