$page not targetting views block but $is_front is. Need help with trying to solve this in any way 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

&lt;?php if ($page): ?&gt;
&lt;?php if ($view_mode == 'full'): ?&gt;
// Node
&lt;?php endif; ?&gt;
&lt;?php if ($view_mode == 'teaser'): ?&gt;
// Views list
&lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;


doesn't work. The opposite works fine on the front page:

&lt;?php if ($is_front): ?&gt;
&lt;?php if ($view_mode == 'teaser'): ?&gt;
// Node
&lt;?php endif; ?&gt;
&lt;?php if ($view_mode == 'full'): ?&gt; 
// Views list
&lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;


I tried &lt;?php if ($page == 1): ?&gt; 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:

    &lt;a class="full-link" href="&lt;?php echo $node-&gt;field_download_link['und'][0]['value']; ?&gt;"&gt;
        &lt;div class="full-parent-episode-container"&gt;
            &lt;div class="full-parent"&gt;
                &lt;span&gt;&lt;?php print render ($content['field_parent'][0]['#markup']); ?&gt;&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="full-episode"&gt;
                    &lt;span&gt;&lt;?php echo $node-&gt;title; ?&gt;&lt;/span&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/a&gt;


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.

        &lt;?php $block = module_invoke('views', 'block_view', 'sidebar_popular_full_view-block'); ?&gt;
            &lt;?php print render($block['content']); ?&gt;
See template_preprocess_node() for details on how the $page variable is created.


It is this:

$variables ['page'] = $variables ['view_mode'] == 'full' &amp;&amp; node_is_page($node);


So it is only for the full view mode and only if you are viewing the node page of the node that is currently being themed.

So something like this will not work because $page will not be true if $view_mode == 'teaser':

&lt;?php if ($page): ?&gt;
  &lt;?php if ($view_mode == 'teaser'): ?&gt;
    // Views list
  &lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;



There is also currently a bug in the views module where if you have a view on a node page and one of the results of that view is the same node as the one whose page you are on then views will break the $page variable in the node template, causing it to always be FALSE.


To see if that is part of your problem try the patch at https://www.drupal.org/node/1574806


I would not theme a view mode differently in different places. For example the teaser would always look the same regardless of what page it was on. Then you just use:

  


If you are using teaser already for something else then use a different view mode (you could use the entity view mode module for this if you don't want to code it).