Book Image

Drupal for Education and E-Learning

Book Image

Drupal for Education and E-Learning

Overview of this book

Table of Contents (22 chapters)
Drupal for Education and E-Learning
Credits
About the Author
About the Reviewers
Preface
Index

Using Views and PHP Snippets Together


Individually, both views and PHP snippets let us do some amazing things; when used together, we have even more options. In this section, we will cover one technique that uses a snippet to pass arguments to a view. This technique can be adapted to different contexts to provide some very powerful methods of creating dynamic navigation paths through content.

This can be very useful when tracking posts in a site that uses Organic Groups. In our example, we will create a view that takes two arguments: the group id and the user id. These two arguments will allow us to display all of the posts created by a specific user in a specific group.

Our PHP snippet will display a list of groups to which the currently-logged in user belongs. The membership of each group will also be listed, and clicking on a username will pass the arguments—the group id and the user id—to the view.

Creating the View

To create this view, we will clone the Node view: tracker view that ships...