I wrote this poorly the first time, more succinctly:
I need a custom node.tpl for the same content type in the front page teasers, the node itself, and a views listing of that node in the sidebar on every page. The problem is the front page uses teasers, while the nodes use full view, so I can't edit the markup of the sidebar nodes with just $page or $teaser because they would share the markup with the main content of either page.
The front page uses teasers to display nodes. I want different markup in the sidebar for the "most popular" views block, so I set it to use full view. This works fine on the front page.
The problem is on the individual nodes. I can't target the views block's markup in node.tpl. I made an identical views block with teaser view (because nodes use full view) instead but
<?php if ($page): ?>
<?php if ($view_mode == 'full'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'teaser'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>
doesn't work. The opposite works fine on the front page:
<?php if ($is_front): ?>
<?php if ($view_mode == 'teaser'): ?>
// Node
<?php endif; ?>
<?php if ($view_mode == 'full'): ?>
// Views list
<?php endif; ?>
<?php endif; ?>
I tried <?php if ($page == 1): ?>
as well, though I'm not sure if that's used.
Either way, why I can't just use views for everything is because 1. it breaks the AJAX of the rate module. Which is fine in the sidebar, but not on the front page. And 2. I'm using a link from within a field like this:
<a class="full-link" href="<?php echo $node->field_download_link['und'][0]['value']; ?>">
<div class="full-parent-episode-container">
<div class="full-parent">
<span><?php print render ($content['field_parent'][0]['#markup']); ?></span>
</div>
<div class="full-episode">
<span><?php echo $node->title; ?></span>
</div>
</div>
</a>
so I can't have all of the "field-" divs, which break the link. If it matters I'm using $block to get the views list, again, to avoid those "field-" divs.
<?php $block = module_invoke('views', 'block_view', 'sidebar_popular_full_view-block'); ?>
<?php print render($block['content']); ?>