zenphoto forums » General Zenphoto Discussion

Alternating styles

(3 posts)
  • Started 4 years ago by joshrodgers
  • Latest reply from joshrodgers
  1. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    I'm not sure how to explain this, but I'll do my best. I'm integrating ZenPHOTO into a website of mine and what I want to do is have each album alternate colors. I am using the default theme that comes with ZenPHOTO. I have seen this done before. PHP counts the albums and the odd albums are given class="whatever" and the even albums are given class="somethingelse".

    I hope I am explaining myself properly. Anyone have any ideas?

    Thanks,
    Josh

    Posted 4 years ago #
  2. Zenphoto development team
    sbillard

    Chief Developer
    Joined: May '07
    Posts: 9,818

    The css is loaded at line7 of album.php in the default theme. There is really no counter for the alubms, so you will have to come up with some way to decide which is 'odd' and which is 'even'. There is an ID on each album, you could use that.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  3. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    I figured it out. Added some php to make it work. My code looks like this:

    <!-- Alternating Album Style Function -->
    <?php
    $counter = 0;
    $remainder = 0;
    $myStyle = "";
    while (next_album()):
    $counter = $counter + 1;
    $remainder = $counter % 2;
    if($remainder == 1)
    {
    $myStyle = "albumcontainer";
    }
    else
    {
    $myStyle = "albumcontainer2";
    }
    ?>

    <!-- Prints the Gallery Albums -->
    <div class="<?php echo $myStyle; ?>" >
    <div class="albumthumbnail">
    " title="<?php echo gettext('View album:'); ?> <?php echo getAnnotatedAlbumTitle();?>" class="albumthumbnail1"><?php printAlbumThumbImage(getAnnotatedAlbumTitle()); ?>
    </div>
    <div class="albumdescription">
    <div class="albumheader">
    " title="<?php echo gettext('View album:'); ?> <?php echo getAnnotatedAlbumTitle();?>"><?php printAlbumTitle(); ?>
    </div>

    <!-- Prints the Album Date -->
    <?php //printAlbumDate(""); ?>

    <div class="albumdescription">
    <?php printAlbumDesc(); ?>
    </div>
    </div>
    </div>
    <?php endwhile; ?>

    Posted 4 years ago #

RSS feed for this topic

Reply

You must log in to post.