Including results along with a form on the same page and theming the results using drupal

半世苍凉 提交于 2019-12-12 10:23:15

问题


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?


回答1:


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);




回答2:


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.



来源:https://stackoverflow.com/questions/4454938/including-results-along-with-a-form-on-the-same-page-and-theming-the-results-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!