主题化/使用 javascript?
一位同事制作了一个小模块,用于根据用户可配置的搜索词检索 Twitter 搜索结果并将其显示在一个块中。
他正在使用 javascript 进行搜索,以将流量保留在客户端,例如: $.getJSON('http://search.twitter.com' 等..
然后,当返回 json 结果时,将它们插入到块中,将返回的数据包装在 html 中并将其附加到块中。
有没有办法可以从 javascript 层使其主题化?如果不将其传回到drupal并失去带宽等使其位于客户端的优势?
A colleague made a small module to retrieve twitter search results based on user configurable search terms and display them in a block.
He is doing the searching with javascript to keep that traffic on the client side, something like:$.getJSON('http://search.twitter.com' etc..
Then when the json results are returned inserting them into the block, wrapping the returned data in html and appending it to the block.
Is there a way that this could be made themeable from the javascript layer? Without it being passed back into drupal and losing the bandwidth etc advantage of having it sit client side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 Drupal 6 开始,通过 javascript 提供/获取动态内容的模块应该通过从 Drupal js 命名空间调用
Drupal.theme('function_name', ...)
将其转换为 HTML。模块可以/应该通过将它们添加到Drupal.theme.prototype
命名空间来提供自己的 js 主题函数(或覆盖)。该机制的工作原理应该与标准主题机制类似,但到目前为止记录还不够充分。请参阅模块转换指南中的此条目,以及本文末尾的示例。
As of Drupal 6, modules providing/fetching dynamic content by means of javascript are supposed to turn that into HTML by calling
Drupal.theme('function_name', ...)
from the Drupal js namespace. Modules can/should provide their own js theming functions (or overrides) by adding them to theDrupal.theme.prototype
namespace.The mechanism is supposed to work similar to the standard theming mechanism, but is a bit insufficiently documented so far. See this entry in the module conversion guide, as well as the example towards the end of this post.
使用 语义 HTML 并使用 < 来设置生成的 HTML 的样式强>CSS。
Use semantic HTML and just style the generated HTML with CSS.
您可以完全使用 CSS 为其设置主题。
You could theme it entirely with CSS.