Member
Member
galatea   2013-01-08, 11:26
#1
hello
i try insert adsense between 2 rows in album.php (zenpage theme), I tried the following code but it does not work

<div id="albums">
<?php $counter =0; ?>
<?php while (next_album()): ?>
<?php $counter ++;?>
<?php if(($count==2) ): ?>
<p>code adsense </p>
<?php endif; ?>

where's my mistake ?
ps: sorry for my bad english
Administrator
Administrator
acrylian   2013-01-08, 12:10
#2
First, if you want the count to start with 1 you should set $count = '';

Also check your nesting. Using endif is possible but really no one does. In the example the while loop is not closed, too.
Member
Member
galatea   2013-01-08, 17:42
#3
sorry, I did not quite understand what you told me (I started in php and it is a bit complicated)
if I put this (without php endif)

<div id="albums">

<?php $count=''; ?>
<?php while (next_album()): ?>
<?php if(($count==2) ): ?>
<p>mon code asdense </p>

<div class="album">
<div class="thumb">
<a>" title="<?php echo gettext('View album:'); ?> <?php getBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(), NULL, 95, 95, 95, 95); ?></a>
</div>
<div class="albumdesc">
<h3><a>" title="<?php echo gettext('View album:'); ?> <?php echo getBareAlbumTitle();?>"><?php printAlbumTitle(); ?></a></h3>
<?php printAlbumDate(""); ?>
<div><?php echo shortenContent(getAlbumDesc(), 45,'...'); ?></div>
</div>
<p style="clear: both; "></p>
</div>
<?php endwhile; ?>
</div>

it gives me an error unexpected $end
Administrator
Administrator
acrylian   2013-01-08, 17:57
#4
If you don't use endif you still need to close the bracket. Please take the time to learn PHP basics at least first before trying to modify a theme.
Administrator
Administrator
fretzl   2013-01-08, 17:57
#5
It should look something like this:

`
<?php $count=''; ?>
<?php while (next_album()): ?>
<?php if($count==2) { ?>
mon code asdense

<?php } ?>

<div class="thumb">
<?php echo gettext('View album:'); ?> <?php getBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(), NULL, 95, 95, 95, 95); ?>



<?php echo gettext('View album:'); ?> <?php echo getBareAlbumTitle();?>"><?php printAlbumTitle(); ?>

<?php printAlbumDate(""); ?>
<div>
<?php echo shortenContent(getAlbumDesc(), 45,'...'); ?>

</div>
<p style="clear: both; ">

<?php $count=$count+1; ?>
<?php endwhile; ?>
</div>
`
Member
Member
galatea   2013-01-09, 08:45
#6
fretzi
thank you for your help, but your code does not work, nothing appears on my site. is that it works on yours ?
Administrator
Administrator
acrylian   2013-01-09, 11:00
#7
There is a `$count++` missing after `while (next_album()):`

I really again like to recommend to get into PHP basics. This is fairly basic stuff and you will be rewarded the more you work on your site.
Administrator
Administrator
fretzl   2013-01-09, 14:54
#8
It works for me.
This is the working and cleaned code for the
`next_album()` loop on `gallery.php` of the Zenpage theme:

`
<?php $count = ''; ?>
<?php while (next_album()): ?>
<?php if($count==2) { ?>
mon code asdense

<?php } ?>

<div class="thumb">
<?php printBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(), NULL, 95, 95, 95, 95); ?>


<?php printBareAlbumTitle();?>"><?php printAlbumTitle(); ?>
<?php printAlbumDate(""); ?>
<div><?php echo shortenContent(getAlbumDesc(), 45,'...'); ?>
</div>
</div>
<?php $count++; ?>
<?php endwhile; ?>
`
If it does not work then something must be wrong with the implementation of the AdSense code.
Member
Member
galatea   2013-01-09, 16:46
#9
your code works perfectly, I'm just an idiot without memory, I had forgotten that I had left the cached pages I could not see advertising appear

thank you very much fretzel.
Administrator
Administrator
acrylian   2013-01-09, 16:53
#10
Good we finally managed (sorry, fretzl, missed somehow that you raise $count at the end but $count++ is nicer..:-)))
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.