将结果与表单包含在同一页面上,并使用 drupal 对结果进行主题化

发布于 2024-10-07 19:11:47 字数 486 浏览 8 评论 0原文

我已经在 drupal 中成功创建了一个页面,该页面在同一页面上显示表单和结果。该表单就像结果的过滤器。结果包括一堆 html,其中包括通过 Chart API 模块 (http://drupal.org/project /图表)。结果通过标记表单元素包含在表单中(从伊顿的评论中获取:Drupal:如何在与表单相同的页面上呈现表单结果)。

由于我无法访问表单 API 范围之外的表单结果(例如页面回调函数),因此我似乎无法真正对结果进行主题化。有没有办法将复杂的结果与表单放在同一页面上并使结果主题化?另外,有没有更好的drupal方式在同一页面上显示表单结果?

I have successfully created a page in drupal that displays a form and results on the same page. The form acts like a filter of the results. The results include a bunch of html that includes google charts via the Chart API module (http://drupal.org/project/chart). The results are included in the form via a markup form element (Got that from eaton's comments here: Drupal: How to Render Results of Form on Same Page as Form).

Since I can't access the form results outside of the scope of the form API (e.g. like the page callback function), I can't seem to really theme the results. Is there a way to place complex results on the same page as a form and make the results themeable? Also, is there a better drupal way to display form results on the same page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-10-14 19:11:47

drupal 中的任何东西都是主题化的——这是让 drupal 变得很棒的另一件事。您可以通过使用 hook_theme() 并在此处设置您想要使用的主题模板以及您希望传递给主题文件的参数来完成此操作。您可以像这样编写主题

function MYMODULE_theme{
  return array(
    'theme_name'=>array(
      'arguments'=>array('parameters'=>NULL)
      'path'=>'path_to_theme_file',
      'theme'=>'template_name'
    ),
  );
}

然后,即使按照帖子中的建议,您也可以在参数可用的任何地方通过调用 theme('theme_name', $parameters); 来调用此主题

Anything in drupal is themeable - which is one more thing that makes drupal awesome. You can do this by using hook_theme() and setting here either the theme template you would like to use as well as the parameters you wish to pass to the theme file. You would write the theme like so

function MYMODULE_theme{
  return array(
    'theme_name'=>array(
      'arguments'=>array('parameters'=>NULL)
      'path'=>'path_to_theme_file',
      'theme'=>'template_name'
    ),
  );
}

Then even as is suggested in the post you can call this theme wherever your parameters are available by calling theme('theme_name', $parameters);

来世叙缘 2024-10-14 19:11:47

我对你的解决方案感兴趣。我们使用视图和暴露的过滤器做了听起来非常相似的事情。对视图结果和表单进行主题化是在 drupal 中要做的非常直接/标准的事情类型。示例:views-expose-form-form_name.tpl.php 和views-view-view_name.tpl.php。表单也可更改,查看hook_form_alter。

I'd be interested in your solution for this. We did very similar sounding things using Views and Exposed Filters. Theming both the results of the view and the form were very straight forward/standard types of things to do in drupal. Example: views-exposed-form-form_name.tpl.php and views-view-view_name.tpl.php. The form is also changeable view the hook_form_alter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文