How to Rewrite the Output of Views with PHP

Advanced Drupal Views

Views is a very powerful tool that allows you to pull information from your database in many flexible ways.

However, there will be situations where the default options in Views aren’t enough. The Views PHP module allows you even more flexibility.

In these two videos, Robert Ring, one of our Drupal teachers, shows you how to re-write a View using PHP.

These videos are part of a longer class called Advanced Views.

Limit the Output of Views with PHP #1

In this first video, Robert shows you how to install the Views PHP module and set up your view.

Limit the Output of Views with PHP #2

In this second video, Robert shows you how Views PHP works. You can pull in all your different fields as variables:

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

    View all posts
0 0 votes
Article Rating
Subscribe
Notify of
guest

7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Anonymous Coward
Anonymous Coward
10 years ago

What’s that wistia thingy?

Nick Savov
10 years ago

It’s fixed now and you should be able to see the second video. Thanks for reporting the issue.

Larowlan
Larowlan
10 years ago

Please don’t encourage people to enter php via the ui, instead teach them to write plugins and use theme hooks.

Paulius Pazdrazdys
Paulius Pazdrazdys
10 years ago
Reply to  Larowlan

Agree. Having PHP in Views is both insecure and not maintainable. So, it’s really bad idea to do it. Learned it myself 🙂

steve
steve
10 years ago

Point taken guys. I’ll add a note to the blog post.

Gilberto
Gilberto
7 years ago

Hello, Do you have a way to create calc (Total) on columns, using filter and views, I dont know using views or custom.
Thanks

Dave
Dave
6 years ago

How to display the field image??

$row->field_image

7
0
Would love your thoughts, please comment.x
()
x