Module Development

Movie Project: Integrate Ajax Functionality for Drupal 7

Check your version

This tutorial covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Render content which can be refreshed via Ajax.

Goal

Update the results of a view using Ajax.

Prerequisites

You will need the following knowledge and skills. If you need a review, check out the Additional resources section at the bottom of this page.

  1. Designing architecture to create Ajax behavior.
  2. Embed views programmatically.
  3. Return content via an Ajax request.

Tasks

Write the steps which will be involved in creating an Ajax-enabled content area. Begin with the step of getting markup of a rendered view, using the tids from the user preferences as arguments.

Create the necessary view which will return film suggestions.

Create markup to render the film suggestions.

Ajax-enable the film suggestions area using jQuery. Use a button to trigger the Ajax request.

Recap

  • Any Ajax-related functionality needs to be well thought out.
  • We can render views programmatically to create custom content in pages.

Further your understanding

Additional resources

Creative Commons License

Drupal Training Resources by Damian Robinson are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.damianrobinson.co.uk.

Hands-On Exercises: Movie Project