0

With a group of several people we're creating a system for students.

Now, on that system we're going to have all kinds of modules that have output, e.g., content types with information about events, a page with a hierarchy of people and groups.

What is the Drupal way of rendering this output?

I know that rendering should be done by the themes. But the problem is that our users should be able to pick a theme they want. Creating separate output for each of those themes is just unfeasibly hard.

3 Answers 3

1

I know that rendering should be done by the themes.

That is not exactly correct. Theme functions are generally defined from modules, and themes can override them, or implement a theme function that is specific for a purpose.

If you are creating the output for a page, the code for generating it should be in a module. That is because it's a module that can implement hook_menu(), which is the hook that defines the menu callback used for pages.
That is what is done from Drupal core code with node_view(), which is the page callback for node/%node, and node/%node/view. The page callback is defined from the Node module, not from a theme; themes can eventually alter the output of node_view() through the node.tpl.php template file used from node_view() to render the node page.

As for outputting the result, there are two methods:

  • Returning a string containing the HTML output
  • Returning an array with a specific structure (it is called render array) that can be used from drupal_render()

As example of a page callback that returns a string, see aggregator_view(); as example of page callback that returns a render array, see node_view().

0

Lots of EDUs use drupal (including mine). For instance Harvard created Open Scholar to power alot of its sites.

The best way to render content in D7 is render arrays from your modules.

Pick a sub-set of drupal modules to support. Create a base theme that implements decent CSS selectors and coloring across all these modules (and their output), allow users to create sub themes -- or colorize your base theme.

Thats about as flexible as you can get.

0
0

I'd also recommend using Skinr. It allows you to preset classes for certain objects/entities. For example, there's a block being placed on a page, and you make a class for blue, red, and green. The user can then say, "Let this be green!" and there you have it.

It might be something worth looking into.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.