Hi. I'm trying to understand a fairly fundamental Drupal architecture aspect. The oversimplified question is: When does a views query run? But the real scenario is this:
- I create a view with a block display type -- doesn't matter what it is.
- In Admin/Blocks, I enable that view to appear in my left sidebar.
So now the view will be active in some way for any node on my site, as long as that node can display a left sidebar.
3.. In Admin/Blocks, I configure that view to only appear on pages entitled 'whatever'
So the real question is: When does Drupal try to run that view's query: On every page with a left sidebar? Or only on the 'whatever' page? In other words, which block configuration setting takes precedence, the one that runs it on 'whatever' or the one that puts it in left sidebar?
Sorry if this is too basic. I get obsessed with details like this.
Thanks.
Comments
Technically, that's not a
Technically, that's not a Views question, that's a question about the behavior of Drupal's block visibility code.
The answer to the question you actually asked: "A view has a 3 stage process: Build, execute and render. Execute actually runs the query." Obviously, that answer isn't very helpful. =)
In the Drupal side of the question: All blocks that are placed in all regions are rendered on every page. However, the 'block visibility' code does run and if it does not pass, that block is not actually rendered.
Since the block is not rendered, the query is not run.
You can confirm this, too. On the Tools tab in the Views UI, there is a checkbox to provide devel information, if you have the devel module. I recommend this. One of the things that it does is tell you the time spent on executing views that are in your blocks.
Thanks
Thanks, Merlin. That answers my question perfectly. And I'll start using devel.