Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.2
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2008 at 21:13 UTC
Updated:
3 Feb 2010 at 18:53 UTC
Is it possible to check view id/name from node template?
I prefer theming with node-nodetype.tpl.php, than with view-....tpl.php files,
so I'd like to use code like:
<?php if ($view == 'view-name'): ?>
...
<?php elseif ($view == 'other-view-name'): ?>
...
<?php endif; ?>...
Is this approach possible?
Szy.
Comments
Comment #1
szy commentedNo one...? :]
Szy.
Comment #2
szy commentedOk, thanks to seutje and marcvangend on irc... I know that is impossible in D6.
Closing... :/
Szy.
Comment #3
szy commentedOk, thanks to seutje and marcvangend on irc... I know that is impossible in D6.
Closing... :/
Szy.
Comment #4
szy commentedHuh, I don't know why, what I was doing wrong before, but... magic - it works like
a charm now!
Example, how to easily theme your custom node type with thumb and title only
on front page - put in your node-yourcustomnodetype.tpl.php template:
It's a lot more efficient for me than playing with views' nested template.
:]
Szy.
Comment #5
merlinofchaos commentedThe reason what you were doing before wasn't working was you were checking $view, not $view->name. The former is an object and will never equal a string.
Comment #6
dan.crouthamel commentedI'm using contemplate to provide the output for my custom node and I would like to know whether or not I'm in a view - views slideshow block to be specific. Unfortunately, this approach ($view->name) isn't working for me - it's empty. I must be doing something wrong :(
--- Update ---
Odd, I had a CCK Datestamp field in my custom content type. For whatever reason, the $view variable was not available. I removed the field and now it's there. Thought it was a fluke, so I added the field back and the variable is not available. Removed it, and it is.
Comment #7
szy commented@Dan, there is a problem with latest releases of Date module. Check this issue to make
your with-date-views working again:
-> #348241: Upgrade to 6.x-2.0-rc6 causes node-view template suggestions to fail
Szy.
Comment #8
dan.crouthamel commentedAhh, thanks for pointing that out to me :)
Comment #9
merlinofchaos commentedTitle reset
Comment #10
lias commentedGood information, thank you,.