Display custom content using a render array.
Objectives and Prerequisites
You will need the following knowledge and skills. If you need a review, check out the Resources section at the bottom of this page.
- Have a page return custom content.
- Create a render array.
- Register and create theme functions.
Tasks
Create a menu hook to link to a callback which will contain the render array. The callback function should be in a new file.
Return a render array from the function with test content.
Register and call a theme function to display the user's favorite film.
Register and call a theme function for the favorite film component. Use a template file to display the components of the content.
Summary
- Custom pages can be created and returned by creating a render array.
- Custom theme functions can be registered in a custom module, using theme functions to contain markup, or template files to create markup.
Resources
- API Documenation: hook_theme (api.drupal.org)
- Documentation: Using the theme layer (drupal.org)
- Video: Using the Drupal Render API (Drupalize.Me)
- Video: Integrating with the Theme System (Drupalize.Me)