Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By pamphile on
How do I force code within the node.tpl.php to only appear on full pages, and not on the frontpage ?
I am making modifications to my phptemplate , node.tpl.php but I don't want these modifications too appear on the frontpage.
Appatently the homepage also uses node.tpl.php.
Comments
use is_front
I think you can use a thing called
is_front
you can use...or more to the point "if this isn't the front page..do this"..if (!$is_front):
DO STUFF IF THIS ISN'T THE FRONT PAGE
endif;
Hope that helps..is_front definitely works with page.tpl.php...and assume it will work with node.tpl.php as well.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Perhaps more versatile
if ($page == 0):
DO STUFF FOR PAGE DISPLAYendif;
This works for node displays, taxonomy displays, any multi-node display. Not sure if the is_front query would do the same.
Conversely, you also can do:
if ($page != 0):
DO STUFF FOR NODE-ONLY DISPLAYendif;
===
Laura
pingVision
_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet
good point
yep. good point Laura..that is probably better to use instead of the is_front..
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
It worked... !! :)Thanks
It worked... ! :)
Thanks to Laura and Dublin
Wholesale DIrectory
Business Letters
Football News
$is_front is strictly for the actual frontpage
I realised this the hard way :-)
A theme developer should almost always use
if($page==0)
instead ofif($is_front)
.$is_front is set strictly for the front page. If you click on a taxonomy term then the resulting page (which looks like the frontpage but has only those nodes that are classified under that specific taxonomy term) does NOT have $is_front set.
Thanks everybody.
My Drupal-powered Blog: ThoughtfulChaos
don't have it set in front page
I never have $is_front set, neither with the front page. I understand that front page can be any page especified in the main settings form. Have this been changed with v.4.6.6?
---
Robert Garrigos
Professional site:robert.garrigos.org
Hiding Breadcrumbs
A good use for $is_front would be to hide the breadcrumbs. I'm doing that with a theme, so the padding and stuff isn't generated for the front page:
If you don't do that, it puts "
", or something like that on 'node'.
--
Bradlis7.com | Churchofchristnet
$page is never set
On my Drupal 4.7.2 site $page is never set, regardless of if page is the homepage or not :(
I have one template for the homepage and another for the rest of the site. mysite.com/ works fine with $is_front , but mysite.com/index.htm (defined as such in settings) does not. Bug?
I found the solution that may be not perfect, buy works fine for me
Regards,
Jacob.
I'm not sure $is_front still
I'm not sure $is_front still works.
For me I had to replace $is_front with the test $_REQUEST["q"]=="" (which should evaluate to true on the main page www.yourSite.com)
So this code might display breadcrumb on all page but the home page (ie www.blabla.com or www.blable.com/Home_Page_As_Defined_In_Settings):
Tchao,
Chris D.
Tech. articles with a WAMP+IIS+Drupal focus
Take a break: Guide to France
I have Drupal 4.7.2 and
I have Drupal 4.7.2 and $is_front seems to be never set
I use
I had the same problem, so I
I had the same problem, so I used this. It works now.
On my drupal 4.7 site, page
On my drupal 4.7 site, page is always set to 0, even on full-node views. how is that possible?
-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes
$page never set
I'm noticing this too. $page never seems to be set. I'm on 4.7.3
Anyone know anything about this?
distinguish between node listings (teaser page) & content pages
I'm having this same problem. Using 4.7.3 In node.tpl.php
if ($page == 0) {
works fine to make the distinction, but it doesn't work in page.tpl.phpI don't know why this is, but now I can't distinguish between these page types within the page template, which is kinda important.
Anyone know of a fix or alternative?
Michael
www.webemulsion.com
ok Now how do I check if I
ok
Now how do I check if I am browsing a taxonomy ?
Marcel
http://www.acmetutorials.com
This is what I use
I use the following test to see if I am browsing taxonomy
For my front page and a little bit more
It's more than just the front page...
-----------------
Chic Velvet
the distinction
$is_front = use this for template, like page.tpl.php
drupal_is_front_page() = use this in block, node or other
help with the elseif statement in page.tpl.php
i'm using this statement in page.tpl.php
i would like the front page to display flash
i would like the node 24 to display a single .png file
and i would like all other pages to display the javascript
the front page and node 24 work perfectly. however, all other pages do not. they display the single .png file as well and not the javascript. i'm thinking
<?php else ($page == 0) : ?>
is not working. any ideas/suggestions?
thanks!
shane
[Added <code> and </code> tags: nevets]
Two things I see 1) There is
Two things I see
1) There is no default "$page" in page.tpl.php, you could replace
else if ($page == node/24)>
withelse if ( $node->nid == 24 )
.2)
else ($page == 0)
should just beelse
(Side note, in
$page == node/24
, node/24 needs to be in quotes, ie 'node/24')