我如何通过node_type获取分类词汇
我的节点类型很少,其中一些有一个与分类词汇相关的额外字段。如果我知道该字段存在的字段名称和节点类型,如何获取分类词汇 ID 或名称?
I have few node types and some of them have an extra field is linked to taxonomy vocabulary. How can i get taxonomy vocabulary id or name if i know field name and node type where this field there exists?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Drupal 7 中,字段可以添加到任何实体/包中,并且对于术语参考字段,使用的词汇表是在字段级别设置的,而不是在实体/包级别上设置的。
因此,您不需要查询特定内容类型的字段设置,而只需查询字段本身的设置。词汇机名称存储在从
field_info_field()
:希望有帮助
In Drupal 7 fields can be added to any entity/bundle, and for a term reference field the vocabularies used are set on the field level, not on the entity/bundle level.
So you don't need to query the field settings for a particular content type, but simply the settings for the field itself. The vocabulary machine names are stored in the
allowed_values
key of thesettings
array returned fromfield_info_field()
:Hope that helps
如果您在额外字段中保留术语,则此代码非常有用。
This code is useful if you keep term in your extra field.