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.

0 0 votes
Article Rating
Subscribe
Notify of
7 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Anonymous Coward
Anonymous Coward
9 years ago

What’s that wistia thingy?

Nick
9 years ago

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

Larowlan
Larowlan
9 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
9 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
9 years ago

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

Gilberto
Gilberto
5 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
5 years ago

How to display the field image??

$row->field_image

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