将现有的 cck 字段附加到 Drupal 中的现有内容类型
如果不通过 UI,我如何将现有的 CCK 字段类型添加到 Drupal 中的现有内容类型中?
我想象我可以将配置更改直接添加到“安装”文件中的数据库中,但如果没有,我应该调用哪个挂钩?
Without going through the UI, how would I add an existing CCK field type to an existing content type in Drupal?
I'm imagining I could add the change of configuration straight to the database in an 'install' file, but if not, which hook should I call for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,没有任何钩子可以做到这一点。
最不痛苦的方法可能是使用 CCK 的内容复制子模块来生成代表您的领域的 PHP 代码。然后,您可以将该 PHP 代码输入到
content_copy_import_form()
中,或者将代码从content_copy_import_form_submit()
复制到单独的实用程序函数中。 (这些是内容复制用于导入/导出操作的内部函数,并不是真正要以这种方式使用。因此,在乱搞之前请仔细准备并了解发生了什么。)另一种方法涉及安装一些新的自定义模块位于 http://neminis.org/blog /drupal/programmatic-cck-content-types-updated/。如果您发现自己经常这样做,这可能是一个更易于维护的解决方案。
There's no hook that does this, as far as I know.
The least painful way would probably be to use CCK's Content Copy submodule to generate PHP code that represents your field. Then you could feed that PHP code into
content_copy_import_form()
or copy the code fromcontent_copy_import_form_submit()
into a separate utility function. (These are the internal functions that Content Copy uses for it's import/export operations, and weren't really meant to be used this way. So, ready carefully and understand what's going on before you mess around.)An alternative method that involves installing some new custom modules is at http://neminis.org/blog/drupal/programmatic-cck-content-types-updated/. This might be a more maintainable solution if you find yourself doing it a lot.