I'm probably not saying this right. What I've got is a view I've set to display nodes of a particular content type... in a block on my front page. Because it looks nicer, I've got the "rowtype" set to node, so it doesn't use fields.

What I want to do is change what order it prints the fields in compared to front page. Put the meta stuff after rather than before, but still have it before on front page stories.
So what I'm thinking is some kind of conditional in node.tpl.php that looks at the content type maybe? Is that possible? Never attempted anything like this though I've done some cut and paste in node.tpl.php.
Am I on the right track?

Comments

ckng’s picture

In your node.tpl.php

  <?php if ($is_front): ?>
    // if front page, do it differently
  <?php else: ?>
    // other pages, you might want to check also $page (full node) and/or $teaser
  <?php endif; ?>
dnewkerk’s picture

If you want to do it based on the fact that the nodes are being shown "in a specific view" (not just the front page) then this code may help: http://drupal.org/node/387036
I tested it out and it works well (you can remove all the extra data printing). I'm not sure how to get it to work for a specific "display" of a view, but hopefully someone can answer that if you need it.

You can definitely use fields in view though when needed... how it "looks" is entirely up to you. Here's another post where I explained how to theme Views fields the way I personally prefer to http://drupal.org/node/368691#comment-1236820 ... with this way you can pretty easily "emulate" your node template if you want. You can also use separate templates for each individual field, but I don't prefer so many template files (rather a single file similar to a node template).

aharown07’s picture

Thanks. I think I should be able to do it w/this info!

Edit: actually, the posts you mentioned seem to refer to Views pages.... unless I read wrong. What I'm trying to do is change display of a view in a block on my front page.
I suppose I could use fields and try to style them all, but I'm looking for an easier way. Right now, when I change the row style to fields, the teaser links all disappear.

dnewkerk’s picture

Worked on the code a bit more, and discovered about views_get_current_view().
Here is a working example. The View I'm using is a simple View which lists node teasers of Story nodes, and has both a Page display and a Block display added. The Block has been enabled at admin/build/block.

The following code is currently added to node.tpl.php (if appropriate for the actual use-case, ideally it ought to be switched to a preprocess function to keep complex PHP logic separate from the theme files):

<?php
  $view = views_get_current_view();
  // Get the View name
  $viewname = $view->name;
  // Get the display ID (a View can contain multiple Displays)
  $display_id = $view->current_display;
  
  if ($viewname == 'story_nodes') {
    print "<p><strong>This is the story_nodes View.</strong></p>";
  }

  // Displays within a given View have a unique ID, which we can now make use of.
  // Hover over the display's side tab in Views to see its internal ID.
  if ($display_id == 'page_1') {
    print "<p><strong>This is the page_1 display.</strong></p>";
  }
  
  if ($display_id == 'block_1') {
    print "<p><strong>This is the block_1 display.</strong></p>";
  }
  
  // Example combining test for block_1 and whether it is showing on the front page.
  if ($display_id == 'block_1' && $is_front) {
  print "<p><strong>This is the block_1 display on the FRONT.</strong></p>";
  }
?>
aharown07’s picture

I think it get it. Then I'd be pasting in the code from my current node.tpl.php w/the changes I want... in place of "this is the block_1 display", am I right?
Many thanks.