Views Dependencies
I found an interesting "gotcha" the other day. I created a View with the Views module, exported it to code and was in the process of trying to make it appear on my website. Something it was resolutely refusing to do. I couldn't understand it. Clearly there was the View in my code. I'd cleared caches, run the update, uninstalled and reinstalled my module, even restarted Apache. Nothing!
Then I noticed this line:
<?php
$view->requires = array(node, node_data_field_media_embedded_video, image, node_data_field_mp3);
?>When you create a View which uses fields, for example a Table or List View instead of Full Node or Teaser, then those fields become dependencies on your View working properly. In this instance, node_data_field_mp3 did not exist because on the website I hadn't imported the content type yet. I expected the View to work anyway, but it did not. It simply did nothing until all the dependent fields were available.

Post new Comment