Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-12-14 10:59:08

shrimpdesign
New Member
Registered: 2006-12-14
Posts: 5

Custom Next/Previous links

I have a nice Textpattern site that I made recently for my personal Portfolio.
http://shrimpdesign.com

I made custom fields for 4 images URLs for each portfolio item, so that there are 4 different views of that portfolio piece.

I want to make a Previous/Next links that grabs a custom field from the previous and next portfolio items when viewing a single item. Because I want to have a graphical representation of the next and previous item, I’d rather have a little preview than just the title.

I tried using an <txp:older> tag with an <txp:article> inside of it, but I think it doesn’t work on the invididual page, and <txp:link_to_prev> only works with <txp:prev_title />.

Are there any workarounds?

Last edited by shrimpdesign (2006-12-14 11:24:47)

Offline

#2 2006-12-14 11:15:44

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Custom Next/Previous links

You’ll need to make two more custom tags. The globals you are interested in are $prev_id and $next_id.

Offline

#3 2006-12-14 11:26:58

shrimpdesign
New Member
Registered: 2006-12-14
Posts: 5

Re: Custom Next/Previous links

Sorry, I meant custom fields. I made custom fields for the images.

But it looks like I have to make my own plug-in, is that right? Using $prev_id and $next_id?
I guess I’ll look at textbook for info about making plug-ins.

Offline

#4 2006-12-14 11:34:28

shrimpdesign
New Member
Registered: 2006-12-14
Posts: 5

Re: Custom Next/Previous links

Or wait, maybe I could do it with the handy tip at focusontheclouds ?

Just use <txp:php> and access the globals to get the next_id’s custom_field? Is that possible?

Last edited by shrimpdesign (2006-12-14 11:35:34)

Offline

#5 2006-12-14 11:43:26

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Custom Next/Previous links

Yes, it’s possible. Either way does mean creafting a little more PHP than that, though.

Offline

#6 2006-12-14 11:46:05

shrimpdesign
New Member
Registered: 2006-12-14
Posts: 5

Re: Custom Next/Previous links

Ok, thanks for your help Mary!

Offline

#7 2006-12-14 20:17:04

shrimpdesign
New Member
Registered: 2006-12-14
Posts: 5

Re: Custom Next/Previous links

I figured it out.

<ul>
<txp:php>
global $pretext, $next_id;
$next_custom_1 = safe_field('custom_1', 'textpattern', "ID='".$GLOBALS['next_id']."' limit 1");

echo "<li class=\"thumb-next\"><span style=\"background: url(" . $next_custom_1 . ") center center no-repeat\"><txp:link_to_next>next</txp:link_to_next></span></li>";

</txp:php>

<txp:php>
global $pretext, $prev_id;
$prev_custom_1 = safe_field('custom_1', 'textpattern', "ID='".$GLOBALS['prev_id']."' limit 1");

echo "<li class=\"thumb-prev\"><span style=\"background: url(" . $prev_custom_1 . ") center center no-repeat\"><txp:link_to_prev>previous</txp:link_to_prev></span></li>";

</txp:php>
</ul>

Offline

Board footer

Powered by FluxBB