Forum Moderators: coopster

Message Too Old, No Replies

conditional script(?), not sure what i need.

         

PiratePictures

6:28 am on Mar 21, 2010 (gmt 0)

10+ Year Member



i'm working on a gallery in a wordpress site and am still learning. I'm trying to make previous/next links at the bottom of a picture post that when clicked will take the user to the previous or next image.

this is the css:

.previmgtxt {
position:absolute;
z-index:-1;
float:left;
width:110px;
height:110px;
color: #ffffff;
font-size: 30pt;
line-height: 22pt;
background-color: #000000;
padding: 20px;
}
.previmglink:hover {
opacity:.2;
filter:alpha(opacity=20);
}

and this is the html to go with it:

<div class="navigation">
<div class="alignleft"><div class="previmgtxt">PREV IOUS PIC</div><div class="previmglink"><?php previous_image_link() ?></div></div>
<div class="alignright"><div class="nextimgtxt">NEXT PIC</div><div class="previmglink"><?php next_image_link() ?></div></div>
</div>

it works perfectly except for on the very first photo where there is no previous photo it will still show the "PREVIOUS PHOTO" image since its in a separate div.

I need a php code (?) to make sure that when the post is on the first page (or when there is no 'previous' photo) then nothing shows up.

Hope i explained that well enough. if not, check out the site here: <snip>

and the problem here: <snip>

thanks in advance.

[edited by: dreamcatcher at 10:34 am (utc) on Mar 21, 2010]
[edit reason] no urls please, see T.O.S [/edit]

Matthew1980

4:35 pm on Mar 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there PiratePictures,

Not sure if this was a typo but thought I would mention it anyway ;-p

In your html, when you break into php this is wrong:-

<div class="navigation">
<div class="alignleft"><div class="previmgtxt">PREV IOUS PIC</div><div class="previmglink"><?php previous_image_link() ?></div></div>
<div class="alignright"><div class="nextimgtxt">NEXT PIC</div><div class="previmglink"><?php next_image_link() ?></div></div>
</div>


Your missing the ; from the functions (previous_image_link(); & next_image_link();)

And the pseudo code for not showing the first picture would be something like:-

if(isset($_GET['page_or_picture_number_here']) && ((int)strip_tags($_GET['page_or_picture_number_here']) == "1"))
{
//show nothing
}
else{
// more than page 1, show previous image
}

I'm just using (int) to force the value held in $_GET to be a whole number & strip_tags(); to strip anything potentially harmful from the URL value, always worth doing IMHO ;-p

This is assuming as your using the URL to catch the page/picture numbers, hopefully you can see what I mean from this though.

Cheers,
MRb