Member
Member
mcemrn   2016-09-15, 10:51
#1
Hello, i am new to this forum and i am trying to insert Adsense code between albums.

I found this old thread: http://www.zenphoto.org/support/topic.php?id=32466 but it is three years old.

Can you help me please to adapt fretzl Member Staff Forum old code to new version 1.4.13 ?

In album.php file the unmodified code is:

`
<?php while (next_album()): ?>

<div class="thumb">
<?php printAnnotatedAlbumTitle(); ?>"><?php printAlbumThumbImage(getAnnotatedAlbumTitle()); ?>


<?php printAnnotatedAlbumTitle(); ?>"><?php printAlbumTitle(); ?>
<small><?php printAlbumDate(""); ?></small>
<div><?php printAlbumDesc(); ?>
</div>
</div>
<?php endwhile; ?>
`
Administrator
Administrator
fretzl   2016-09-15, 11:17
#2
Correct me if I'm wrong but I believe you tried to add code from album.php from the basic theme? So I edited it. Code should always be between "backticks" (`)
Member
Member
mcemrn   2016-09-15, 11:22
#3
Hello fretzl, yes, i am trying to add code in album.php from the basic theme, thanks for editing it with backticks
Administrator
Administrator
fretzl   2016-09-15, 11:24
#4
The code from the old post should still work...BUT you will have to change getAlbumLinkURL() to getAlbumURL()
Administrator
Administrator
fretzl   2016-09-15, 11:35
#5
Just noticed that the code from the old post is specifically for the Zenpage theme.(thumbs are generated a bit different)

Here's the code that should work for the basic theme:
`
<?php $count = ''; ?>
<?php while (next_album()): ?>
<?php if($count==2) { ?>
your Adsense code here

<?php } ?>

<div class="thumb">
<?php printAnnotatedAlbumTitle(); ?>"><?php printAlbumThumbImage(getAnnotatedAlbumTitle()); ?>


<?php printAnnotatedAlbumTitle(); ?>"><?php printAlbumTitle(); ?>
<small><?php printAlbumDate(""); ?></small>
<div><?php printAlbumDesc(); ?>
</div>
</div>
<?php $count++; ?>
<?php endwhile; ?>
`
Member
Member
mcemrn   2016-09-15, 12:02
#6
Thanks fretzl ! It works ! I added it to index.php so i can not put Adsense between albums.

I want to add Adsense code too between images thumbails in album.php
If i am not wrong code to modify is:
`
<?php while (next_image()): ?>

<div class="imagethumb">
">
<?php printImageThumb(getAnnotatedImageTitle()); ?>


</div>
<?php endwhile; ?>
`
Can i ask this code too ? Please i would be very grateful
Administrator
Administrator
acrylian   2016-09-15, 12:26
#7
Within the `next_image` loop it would be the same acually. But of course everything you put in the to loop will be looped, too. So you would get as many adsense ads as there images or albums.

That would be a lot of ads that surely will not keep visitors to your site. You probably want one place of ads on the page. So you probably want to add it outsde the both loops instead? OR as the old code suggest limit the display by checking the loop count.
Administrator
Administrator
fretzl   2016-09-15, 12:34
#8
`
<?php $count = ''; ?>
<?php while (next_image()): ?>
<?php if($count==2) { ?>
your Adsense code here

<?php } ?>

<div class="imagethumb">
">
<?php printImageThumb(getAnnotatedImageTitle()); ?>


</div>
<?php $count++; ?>
<?php endwhile; ?>
`
Depending on where (i.e. after which thumbnail) you want the Adsense code to appear you will probably have to change the number in `if($count==2)`
Member
Member
mcemrn   2016-09-15, 13:16
#9
Thank you fretzl ! Yes, also this code works for me and yes i chosen loop count.

This request can be marked as Solved, thank you very much for the support
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.