使用 Drupal 做 Digg 做的事情
我正在尝试创建一个网站,就像 Digg 一样,用户可以提交链接并使用 ajax 尝试将元数据从页面提取到标题和描述字段中。用户可以更改这些字段中的任何一个,然后提交内容。
理想情况下,模块已经存在。我尝试使用 Feeds,但我不确定我是否找对了地方。
我可能必须创建自己的自定义模块。
有什么建议吗?我可以利用 Feeds API 来解析 url,然后获取结果并自己完成所有映射吗?假设我想创建自己的表单并引入自己的 ajax。
I'm trying to create a site where, like Digg, a user can submit a link and using ajax it attempts to pull the metadata from the page into a title and description field. The user can change either of these fields then submit the content.
Ideally a module already exists. I tried playing around with Feeds, but I'm not sure if I'm looking in the right place.
I probably have to create my own custom module.
Any suggestions? Can I tap into the Feeds API just to parse the url then take the results and do all the mapping myself? Assuming I want to create my own form and bring in my own ajax.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也许可以使用 Feed 来做到这一点,但我认为这可能有点矫枉过正,并且可能难以配置。
您可以使用 hook_form_alter 自定义提交表单,arg() 来确定提交的 URL,drupal_http_request 检索页面,然后是表单 API 的 #default_value 设置以预填充字段。
预填充模块可以完成您想要的很多工作。如果它提供了钩子(我不确定是否提供),您需要做的就是添加 drupal_http_request 来处理元数据的获取。
You could probably do that with Feeds, but I think it might be overkill and could be difficult to configure.
You could do what you're looking for in a relatively small custom module using hook_form_alter to customize the submission form, arg() to determine the URL being submitted, drupal_http_request to retrieve the page, then the Form API's #default_value setting to pre-populate the field(s).
The Prepopulate module does a lot of what you're looking for. If it provides hooks (I'm not sure if it does) all you would need to do is add the drupal_http_request, to handle fetching the metadata.
在 Drupal 中,它称为 Drigg ;)。它应该是一个很好的 Drupal 模块来获得 Digg 的功能。我想这值得一试。
In Drupal it's called Drigg ;). It is supposed to a nice Drupal module to get the functionality of Digg. It will be worth a try I suppose.