Posted by doncheks on November 21, 2012 at 12:27pm
Hey guys,I just downloaded a drupal starter pack.The default theme has a slide show option.Problem is when slideshow is set to yes,it shows on all the site pages.The slideshow is not a block but is coded into the theme's page.tpl.php file, and there is no way to control its visibility from theme settings
I opened page.tpl.php and here is what I found
<!-- Banner Area -->
<?php if(theme_get_setting('slideshow')=='yes'): ?>
<div class = "slideshow-banner">
<div class = "page-center"> <!--page center start-->
<div id="slideshow-area">
<div id="slideshow">
<?php print render($slideshow); ?>
</div>
</div>
</div> <!--page center end-->
</div> <!--slideshow-banner end-->
<?php endif; ?>
</div> <!-- End Header Wrapper -->How do I make the slideshow to show only on the home page.Thanks.
Comments
There are a few ways you
There are a few ways you could approach that.
I would probably copy the page.tpl.php to page--front.tpl.php (note the 2 hyphens). Edit the page.tpl.php file and delete this section:
<?php if(theme_get_setting('slideshow')=='yes'): ?>
<div class = "slideshow-banner">
<div class = "page-center"> <!--page center start-->
<div id="slideshow-area">
<div id="slideshow">
<?php print render($slideshow); ?>
</div>
</div>
</div> <!--page center end-->
</div> <!--slideshow-banner end-->
<?php endif; ?>
Reset the theme registry (if you use drush, drush cc all will do that for you, otherwise go here: http://drupal.org/node/337176).
The slideshow should now appear on the front page, but no other pages
deleted
accidental double post - apologies
Thanks
Thanks man.Will give this a try but was hoping i could solve it by modifying page.tpl.php file.
I checked and there is a module page theme that can allow me to switch themes for pages.
However modifying the php statement to show the slideshow only on the front page will be the best solution.Thanks again.Still trying.
Another way
If you want to avoid creating new template files, you could also extend the conditional in the code there with
if(theme_get_setting('slideshow')=='yes' AND drupal_is_front_page()):. Like this:<?php if(theme_get_setting('slideshow')=='yes' AND drupal_is_front_page()): ?><div class = "slideshow-banner">
<div class = "page-center"> <!--page center start-->
<div id="slideshow-area">
<div id="slideshow">
<?php print render($slideshow); ?>
</div>
</div>
</div> <!--page center end-->
</div> <!--slideshow-banner end-->
<?php endif; ?>
So you're also checking if the front page is the current page.
More about the function I've used at http://api.drupal.org/api/drupal/includes!path.inc/function/drupal_is_front_page/7
Perfect Solution
Thanks boss.twas just what I was looking for.You re right.The module was overkill.Both of the solutions you offered are good.The latter works best.Thanks.
you're welcome :-)
you're welcome :-)
I'd say the module you
I'd say the module you suggested is overkill for your use case. Of course, it may be useful for other things you're trying to do also.