在提交时自动更新drupal节点
是否可以在提交时自动更新drupal节点的内容?
将图像添加到节点时,它们存储为
但是,我们经常将内容分发到客户服务器,因此“myserver”是不正确的。如果我使用 任何人都可以预见任何问题(drupal 始终安装在根级别)。
如果这不会导致任何问题,是否可以自动化,以便在添加任何新内容时,它会扫描“http://myserver/sites”并替换为“/sites”?
提前致谢,
马丁
Is it possible to automatically update the drupal node's content at submit time?
When adding images to the node, they are stored as <img src="http://myserver/sites/....">
However, we frequently distribute the content to customer servers, and 'myserver' is therefore incorrect. If I used <img src="/sites/...."> can anyone foresee any issues (drupal is always installed at the root level).
If this does not cause any issues, can it be automated, so when any new content is added, it scans for 'http://myserver/sites' and replaces with '/sites' ?
Thanks in advance,
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为具体细节实际上取决于您上传图像的方式......要么使用默认的 上传模块或FileField和ImageField (我推荐后者)。
无论哪种方式..您应该能够通过 hook_nodeapi() (当 $op == 'presave' 时)。这样做将需要自定义模块,但不要因此而却步,设置起来非常简单。
要查看该挂钩期间发生了什么,这样您就可以确保文件信息存在并准备好进行编辑。执行此操作(在开发服务器上!):
这应该会告诉您$node 对象中发生了什么,如果您可以找到文件路径,您应该能够在它进入数据库之前对其进行编辑。
当 $op=='view' 时,您也可以使用相同的钩子更改输出。
I think that the gritty details really depend on how you are uploading images... either with the default Upload module or a combination of FileField and ImageField (I'd recommend the latter).
Either way.. You should be able to make adjustments to the node automatically with an implementation of hook_nodeapi() (when $op == 'presave'). Doing so will require a custom module, but don't be deterred by that, it's pretty straightforward to set up.
To see what's going on during that hook, so you can make sure that you're file info is there and ready to be edited.. do this (on a development server!):
That should show you what's going on in the $node object, and if you can find the filepath you should be able to edit it before it gets into the database.
You could also just alter the output with the same hook, when $op=='view'.