Prev_entry next_entry and conditionals
Posted: 30 May 2008 05:37 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  335
Joined  01-25-2006

I would like to be see some attributes on the prev_entry and next_entry function so that when you are at the first or last entry in the list we can still have two items on the page.

Discussed a little in this thread

At the moment if you are at the first item the function does not output anything at all so any page layout gets kind of screwed up:

1st | Next>
2nd <Previous | Next>
3rd <Previous |

What I would like to see is a conditional to allow us to add other html code (so we can add text, code or image etc.) when the prev or Next returns a nill result.

1st <         | Next>
2nd <Previous | Next>
3rd <Previous |     >

- and in example images below.

Image Attachments
prevnext_example 1.gifprevnext_example 2.gif
Click thumbnail to see full-size image
 Signature 

“All men are equal. All men, that is, who possess umbrellas.” E.M. Forster 

Artscape and Santaballs
Chris O’Donoghue Chelsea Garden Designer
The Greenwich and District Narrow Gauge Railway Society
Croydon RFC

Profile
 
 
Posted: 19 August 2008 01:20 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

You can do this with some PHP. I usually make a template called “_prevnext.php”, enable PHP for it, and then embed it where it needs to go. Here is some sample code.

{!-- Confusing, but "next" is actually the previous entry --}

<p class="prevNext">
  
<?php $is_prev = 'n'; ?>
  
{exp
:weblog:next_entry  weblog="weblogname"}
<a class="prev" href="{path=group/template}">Prev</a>
<?php $is_prev = 'y'; ?>
{
/exp:weblog:next_entry}

<?php
if ($is_prev == 'n') { /* do something if prev is empty */
?>

<span class="prevOff">Prev </span>

<?php } ?>

&nbsp;|&nbsp;

  
<?php $is_next = 'n'; ?>

{exp
:weblog:prev_entry weblog="weblogname"}<a class="next" href="{path=group/template}">Next</a>
<?php $is_next = 'y'; ?>
{
/exp:weblog:prev_entry}


<?php
if ($is_next == 'n') { /* do something if next is empty */
?>
<span class="nextOff">Next</span>
<?php } ?>

</p>


Hopefully that helps you out.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 19 August 2008 04:52 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  335
Joined  01-25-2006

Thanks mdesign that’s really helpful! - though I still would like to see it as a conditional as it would be easier to set up for most of us.

 Signature 

“All men are equal. All men, that is, who possess umbrellas.” E.M. Forster 

Artscape and Santaballs
Chris O’Donoghue Chelsea Garden Designer
The Greenwich and District Narrow Gauge Railway Society
Croydon RFC

Profile
 
 
Posted: 03 September 2008 04:19 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  226
Joined  01-20-2006

It’s a valid request in my book too Simon. And thanks for your workaround Ryan, it works well.

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65086 Total Logged-in Users: 34
Total Topics: 82224 Total Anonymous Users: 12
Total Replies: 441921 Total Guests: 207
Total Posts: 524145    
Members ( View Memberlist )