Hello,

I need some help. I'm creating a site with 6 different sections and I want a different static image (or slideshow) on each page. Can we achieve this?

Thanks in advance!

Comments

Deepika.chavan’s picture

Hi,
I tried the same thing on my local site.
1. In page.tpl.php replaced following code

<?php if($is_front): ?>
<div id="slideshow-wrapper">
<div class="slideshow-inner">
<div id="slideshow-preface">
 <?php if ($page['preface']): ?>
          <div id="preface">
            <?php print render ($page['preface']); ?>
          </div><!-- end preface -->
 <?php endif; ?>
</div>
<?php if ($page['highlighted']) : ?><div id="slideshow-bottom">
<div id="mission"><?php print render ($page['highlighted']); ?></div></div><?php endif; ?>
<div class="slideshow">
<img src="<?php print $base_path . $directory; ?>/images/slideshows/sea.jpg" width="950" height="355" alt="slideshow 1"/>
<img src="<?php print $base_path . $directory; ?>/images/slideshows/noon.jpg" width="950" height="355" alt="slideshow 2"/>
<img src="<?php print $base_path . $directory; ?>/images/slideshows/snow.jpg" width="950" height="355" alt="slideshow 3"/>
</div>
</div>
</div>
<?php endif; ?>

by this code :

<div id="slideshow-wrapper">
<div class="slideshow-inner">
<div id="slideshow-preface">
 <?php if ($page['preface']): ?>
          <div id="preface">
            <?php print render ($page['preface']); ?>
          </div><!-- end preface -->
 <?php endif; ?>
</div>
<?php if ($page['highlighted']) : ?><div id="slideshow-bottom">
<div id="mission"><?php print render ($page['highlighted']); ?></div></div><?php endif; ?>
</div>
</div>

2. Created block (here-admin/structure/block). Added following code in the block's body and selected "PHP filter"('noon_1.jpg' image placed in /themes/danland/images directory):

<?php
$img_path= base_path() . path_to_theme();
?>
<img src="<?php print $img_path ?>/images/noon_1.jpg" alt="my noon image" />

Enabled the block in 'Preface top' region.

3.Created such different blocks with different images and enabled them on different pages (used 'Only the listed pages' option).
4.To add css for that region, renamed local_sample.css to local.css. followed the instructions given in this file.
Added following css code in local. css file

#preface {
  margin: 0px;
}

#slideshow-wrapper {
 margin-top: 0px;
}    

4. Cleared cached data. (here- admin/config/development/performance).
Hope this is what you wanted!!

Rgrds,
Deepika Chavan.

gsontag’s picture

Im having a few issues with this.. i follow the code, but get:

$img_path= base_path() . path_to_theme();
?>

rather than the image.... should that be changed to something else, like base_path() to the actual path??

Thanks

-G

Deepika.chavan’s picture

Hi,
Please select php filter in 'Input format'. If the option is not there then enable php filter on module page (here-admin/build/modules), under 'Core - optional' modules section.
HTH !!

Rgrds,
Deepika Chavan.

aconcept’s picture

Well I've got what I wanted by just adding some files in the theme's root folder with names like:

page--node--1.tpl.php
page--node--2.tpl.php
page--node--3.tpl.php

etc, depending on each node's number.

Then pasted the same code on every file and changed only the slideshow code to link on different images or flash.

I've found many different ways while searching, like making subthemes, or replacing some kind of code in page.tpl.php or template.tpl.php, I don't know which one is better, but only this one above worked for me.

Taxoman’s picture

Version: 7.x-1.0-rc2 » 7.x-1.0
Priority: Critical » Normal
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Biff09’s picture

I'd REALLY like to get this functionality. I've followed this thread, and since my site is pretty small the:

page--node--2.tpl.php
page--node--3.tpl.php
etc.

technique would be ok for me. Unfortunately it's not working! Can you provide more information on exactly how this got configured?

To be clear, my desired end result is a *different* slideshow on different pages. Optimally some pages would not have a slideshow, but I'm willing to let that go.

Biff09’s picture

Status: Closed (fixed) » Needs work
Keldaria’s picture

Not that i'm going to support this code in anyway but to help out this is what I used and seems to be working fine.

1. In page.tpl.php Replace

<?php if($is_front): ?>
<div id="slideshow-wrapper">
<div class="slideshow-inner">
<div id="slideshow-preface">
 <?php if ($page['preface']): ?>
          <div id="preface">
            <?php print render ($page['preface']); ?>
          </div><!-- end preface -->
 <?php endif; ?>
</div>
<?php if ($page['highlighted']) : ?><div id="slideshow-bottom">
<div id="mission"><?php print render ($page['highlighted']); ?></div></div><?php endif; ?>
<div class="slideshow">
<img src="<?php print $base_path . $directory; ?>/images/slideshows/sea.jpg" width="950" height="355" alt="slideshow 1"/>
<img src="<?php print $base_path . $directory; ?>/images/slideshows/noon.jpg" width="950" height="355" alt="slideshow 2"/>
<img src="<?php print $base_path . $directory; ?>/images/slideshows/snow.jpg" width="950" height="355" alt="slideshow 3"/>
</div>
</div>
</div>
<?php endif; ?>

With

<?php if($page['preface']): ?>
<div id="slideshow-wrapper">
<div class="slideshow-inner">
<div class="slideshow">
         <?php print render ($page['preface']); ?>
</div>
</div>
<?php if ($page['highlighted']) : ?><div id="slideshow-bottom">
<div id="mission"><?php print render ($page['highlighted']); ?></div></div><?php endif; ?>
</div>
</div>
<?php endif; ?>

2. Ensure PHP Filter module is Enabled (goto modules and scroll down to "PHP Filter" and check the enabled box if it isn't already checked

3. Create a block with the following code, and replace picture locations with the locations of your pictures from the website root.
NOTE: the code below contains the paths to where the normal slideshow images for the danland theme should be located, if your using that directory you should only need to rename the files.

<div class="slideshow">
<img src="/sites/all/themes/danland/images/slideshows/sea.jpg" width="950" height="355" alt="slideshow 1"/>
<img src="/sites/all/themes/danland/images/slideshows/noon.jpg" width="950" height="355" alt="slideshow 2"/>
<img src="/sites/all/themes/danland/images/slideshows/snow.jpg" width="950" height="355" alt="slideshow 3"/>
</div>

Ensure that PHP Code is selected in the format and place the block in the PreFace Top block, then set the first block to apply only to first page down at the bottom by selecting "Only Listed Pages" option and entering "" into box below. Make sure you configure the images above to match what you wish to be displayed on the front page.

4. Repeat step 3 to setup customized blocks for all your pages, make sure you don't have 2 blocks displayed on 1 page or it might mess up your websites look

5. Clear your cache by going to configuration>development>performance and using the clear cache button.

Please note I do not intend to update or support this code. this is just what worked for me, and I thought I'd share it for everyones benefit. I am by no means a PHP master in fact it wouldn't surprise me if something I did above is wrong but hey its working for me so I'm happy with that, and I hope at the very least it might help one of you