Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-06-20 22:29:31

steidljr
New Member
Registered: 2006-02-06
Posts: 4

Next and Previous with Article Image

Hi All,

I am trying to create a nice way to navigate through my entries in one section using thumbnails from the article_image field. They following is the idea I am going for, but I know it won’t work. It will just show the article_image for the current entry I am viewing.

<txp:link_to_next ><txp:article_image /></txp:link_to_next >
AND
<txp:link_to_prev><txp:article_image /></txp:link_to_prev >

I think there is a way to do it with a little php and globals, but I since I am no PHP whiz, I am posting here!

I saw one post where the guy was doing something very similar and I think it would be tweaking his code just a bit. I am just having trouble understanding the array since he is doing the same thing using a custom field rather than the article_image field.

Any help would be marvelous.

Offline

#2 2007-06-21 01:29:55

reid
Member
From: Atlanta, Ga.
Registered: 2004-04-04
Posts: 224
Website

Re: Next and Previous with Article Image

I tried doing this using the plug-in asy_wondertag. It ended up being a little more complicated than I would like, but it works. Here’s the basic code:

<txp:asy_wondertag><txp:article_custom id="<txp:next_id />" form="article_thumb" /></txp:asy_wondertag>

Then for the previous link, substitute <txp:prev_id /> for <txp:next_id /> . The form called, article_thumb, is just the article thumbnail wrapped in a permalink.

However, a problem arises on the first and last image in the series, as there is either no previous image, or no next image, and that code will then show all images. Not the desired effect.

So I added another plug-in, chh_if_data, to give me a conditional option for those situations. I chose to show a random image there, but you could also link to another specific article id.

<txp:asy_wondertag><txp:article_custom <txp:chh_if_data>id="<txp:next_id />"<txp:else />sort="rand()" limit="1"</txp:chh_if_data> form="article_thumb" /></txp:asy_wondertag>

That’s the code I’m using for prev/next thumbnail navigation here.


TextPattern user since 04/04/04

Offline

Board footer

Powered by FluxBB