I am thinking that I have a couple of content types that views would be better at displaying my content. e.g. If an image field is blank, show this default image (this is only a basic example where a view would be preferred over Drupal's default node. i.e. I want to create a view with the node id as an argument and set the views page path to node/%. Are there any drawbacks to this?

  • My first instinct was to respond "Other than it won't work?" but instead, let me ask a hopefully constructive question: "How would your view display any other content types other than the couple you want Views to display? Eg, if this would work, how would your view know to display a node "normally" when people go to node/127 but to enact this foo when people went to node/1473?" – Jimajamma Apr 19 '13 at 22:40
  • Good point, you are right that I cannot do this just for a couple of content types. What I can do is do it for all content types. The point of my question was really to understand the limitations, challenges, performance issues etc with using views to do this. Is this bad practice? Am I just being silly? :) – Nigel Waters Apr 19 '13 at 23:52
  • 1
    Page Manager / Panels makes this super simple. – mpdonadio Apr 20 '13 at 0:00
  • Thanks, but I am very familiar with panels and am more of a context guy. I just wanted to know about using views in this way. :) – Nigel Waters Apr 20 '13 at 4:10

You could, however, do something like this in node.tpl.php:

<?php if ($node->type=='FANCYTYPE'): ?>
  <?php print views_embed_view('name_of_fancy_view', 'default', $node->nid); ?>
<?php else: ?>
  // the rest of the normal node.tpl.php stuff here
<?php endif; ?>

or create a node-TYPE.tpl.php (D6) or node--TYPE.tpl.php (D7) with just the Views logic inside.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.