Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2007-05-13 18:56:15

mattgilbert
Member
Registered: 2006-03-23
Posts: 70

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Ok, I think I’ve tracked down the problem. It looks like the call to strftime() is doing something a little unexpected. For one of my articles that was posted at ’2007-04-07 02:26:27’, it returned ’2007-04-07 03:26:50’, a difference of about an hour. Since I was converting my site to textpattern by posting all the current articles one after another, this hour difference screwed everything up.

So here’s what I’ve changed. Maybe not the neatest fix, but it works for me. In jk_getneighbor, I’ve commented out:

/*
		if ($sortby == 'posted') {
		  $sort_value = strftime('%Y-%m-%d %H:%M:%S', $sort_value);
		   $posted = '';
		}
*/

and replaced it with:

		if ($sortby == 'posted') {
		   $sortby = 'unix_timestamp('.$sortby.')';
		}

This means that strftime is never called, and the unix timestamps are used to compare posted times. This seems to work great. I’ll post if I notice anything strange later on.

Thanks so much for the plugin! I hope this has helped.

Offline

#32 2007-05-17 02:43:18

Jeff_K
Archived Plugin Author
From: Vancouver, British Columbia
Registered: 2005-08-19
Posts: 202
Website

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Strange. If anyone can shed some light on this, that would be great! In the meantime, I don’t see why this can’t just be rolled into the next release?

Last edited by Jeff_K (2007-05-17 02:43:34)

Offline

#33 2007-05-17 21:43:39

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Nice, thanks.

Offline

#34 2007-05-23 19:07:59

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Any ideas: I use this plugin inside articles to show next / prev links in alphabetical order. Would work well… expect I have lots of scandinavian letters in titles (like Ä) which this plugins seems to understand as “A”. So it is not useful anymore because the Ä is at the very end of our alphabets. My article lists are shown in correct order though.

Offline

#35 2007-06-01 12:06:03

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Anyone?

Offline

#36 2007-06-01 15:45:29

Jeff_K
Archived Plugin Author
From: Vancouver, British Columbia
Registered: 2005-08-19
Posts: 202
Website

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

I did a search, but couldn’t come up with much. The plugin uses pretty standard MYSQL order syntax which should auto detect non-english characters. I have very little experience working with alternate character sets, so its going to be hard to track this bug down. I would love to figure it out though. When things cool down with work, I will try and put a bit more time into it.

Offline

#37 2007-06-01 19:10:01

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Ok, nice :) I earlier had basic article lists in wrong order too, because their collation/ lang setting in mysql was wrong. Now when the collation in article field is fixed, they print out right. Should that be enough for this plugin too?

Offline

#38 2007-06-07 15:45:08

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Jeff, thank you very very much for releasing this plugin! It was so awfully needed!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#39 2007-06-24 16:59:58

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

I’ve recently discovered a “loophole” jk_neighbour leaves, an undescribed, more unwanted state I could make use of to create a navigation for certain gallery situations. But you can of course use this as well for matters other than the described one.

Let’s assume you have some pictures in your gallery that resemble each other too much to be represented on the gallery overview pages each with it’s own thumbnail. But on the other hand, when viewed in a larger scale the small differences between them become visible, so you want to show them at least on the individual article pages (see demo below), but only as secondary motifs to the parent image.

The trick now is to use jk_neighbour’s attribute sortby=“posted” and to set the date and time of the parent image and all of it’s children images to exactly the same values (btw, an ideal job for upm_savenew). The consequence is that the jk_neighbour nav (1) can leaf through only those images shown on the gallery overview page (see demo below), leaving out the “children” that kind of hide in a row behind each other on the exact same point in time, and this way the sequential order shown in the gallery overview is kept intact when navigating with jk_neighbour.

But the “hidden” images need their own nav (2), which they will get right now. This nav should appear only on the parent’s resp. their cildren’s page. This can be accomplished by applying the extremely versatile chh_related_articles, which – in my case – creates this nav by detecting a custom field relation. As my client’s similar images often are named identically, I’ve decided to use numbers over names, claiming the help of a further custom field.

Demo:
Gallery overview page
Parent image page (individual article)

As it’s a German site, I’ve added these explaining screenshots:

(1) The nav jk_neighbour creates is this one:

(2) Children images can be reached with the chh_related_articles nav on the right of the image:

Last edited by uli (2007-06-25 19:51:45)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#40 2007-08-23 02:37:45

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Jeff (or anyone else):

I am looking to use this plug in on a current project, but I need it to sortby a custom field. I can not get it to work.

When I try to use it, I only get the “Next” button and it references the same article over and over again.

<txp:jk_link_to_prev sortby="custom_4" >
[SQL (0.001774): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > '' and Section = 'sports'  and Status=4 and Posted < now() 
order by custom_4 asc limit 1]
[SQL (0.001311): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 < '' and Section = 'sports'  and Status=4 and Posted < now() 
order by custom_4 desc limit 1]
</txp:jk_link_to_prev>
<txp:jk_link_to_next sortby="custom_4" >
[SQL (0.001644): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > '' and Section = 'sports'  and Status=4 and Posted < now() 
order by custom_4 asc limit 1]
[SQL (0.001316): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 < '' and Section = 'sports'  and Status=4 and Posted < now() 
order by custom_4 desc limit 1]
[SQL (0.000259): select ID as thisid, Section as section, Title as title, url_title, 
unix_timestamp(Posted) as posted from textpattern where ID = 10]
</txp:jk_link_to_next>

I can use the plug in, but it only appears to work for me if I select sortby=title.

Any guidance would be greatlt appreciated.

progre55

I was on the board a couple of months ago about this topic, but got side tracked and wound up using a different solution. This time I really need this plug in.

Thanks again.

Last edited by progre55 (2007-08-23 02:43:10)

Offline

#41 2007-08-24 18:24:32

Jeff_K
Archived Plugin Author
From: Vancouver, British Columbia
Registered: 2005-08-19
Posts: 202
Website

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

I just uploaded v.46 which should fix the problem. Just realized that TXP only stores custom fields as their field name in $thisarticle.

Let me know if it works for you now.

Offline

#42 2007-08-24 18:45:28

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Jeff_K:

Unfortunately, still not working. Please take a look:

<txp:jk_link_to_prev sortby="custom_4" >
[SQL (0.001481): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > 'baseball' and Section = 'sports'  and Status=4 and Posted < now() order by custom_4 asc limit 1]
[SQL (0.001647): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 < 'baseball' and Section = 'sports'  and Status=4 and Posted < now() order by custom_4 desc limit 1]
</txp:jk_link_to_prev>
<txp:jk_link_to_next sortby="custom_4" >
[SQL (0.001495): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > 'baseball' and Section = 'sports'  and Status=4 and Posted < now() order by custom_4 asc limit 1]
from textpattern where custom_4 < 'baseball' and Section = 'sports'  and Status=4 and Posted < now() order by custom_4 desc limit 1]
[SQL (0.000321): select ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as posted 
from textpattern where ID = 11]
</txp:jk_link_to_next>

Now I see the previous and next link (just one of them each time) but they stick on the same property.

progre55

Last edited by progre55 (2007-08-24 21:25:01)

Offline

#43 2007-08-29 20:42:37

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Jeff:

Just wondering if you had a chance to take a look?

Thanks.

progre55

Offline

#44 2007-08-29 21:00:00

Jeff_K
Archived Plugin Author
From: Vancouver, British Columbia
Registered: 2005-08-19
Posts: 202
Website

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Hey. Sorry, just saw your post. So on a different article, what are you seeing in debug? Do you see “custom_4 < ‘baseball’” or “custom_4 > ‘baseball’”

Offline

#45 2007-08-29 21:26:53

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [plugin] [ORPHAN] jk_neighbour: just like link_to_next/prev, only a bit better

Jeff:

Tried it on another site using the following code:

<txp:jk_link_to_prev sortby="custom_4"> Previous </txp:jk_link_to_prev>
<txp:jk_link_to_next sortby="custom_4"> Next </txp:jk_link_to_next>

When I do so, I get an article with a prev link appearing only.

Below is the code for that page:

<txp:jk_link_to_prev sortby="custom_4">
[SQL (0.001391): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > 'Single Home' and Section = 'model homes'  and Status=4 and Posted 
< now() order by custom_4 asc limit 1]
from textpattern where custom_4 < 'Single Home' and Section = 'model homes'  and Status=4 and Posted 
< now() order by custom_4 desc limit 1]
[SQL (0.000308): select ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as 
posted from textpattern where ID = 10]
</txp:jk_link_to_prev>
<txp:jk_link_to_next sortby="custom_4">
[SQL (0.001347): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 > 'Single Home' and Section = 'model homes'  and Status=4 and Posted 
< now() order by custom_4 asc limit 1]
[SQL (0.001518): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from textpattern where custom_4 < 'Single Home' and Section = 'model homes'  and Status=4 and Posted 
< now() order by custom_4 desc limit 1]
</txp:jk_link_to_next>

When I hit the previous link, I get another article with a next link and the following code:

<txp:jk_link_to_prev sortby="custom_4">
[SQL (0.001490): select ID, Title, url_title, unix_timestamp(Posted) as uposted from textpattern where custom_4 > 
'model property' and Section = 'model homes'  and Status=4 and Posted < now() order by custom_4 asc limit 1]
[SQL (0.001309): select ID, Title, url_title, unix_timestamp(Posted) as uposted from textpattern where custom_4 < 
'model property' and Section = 'model homes'  and Status=4 and Posted < now() order by custom_4 desc limit 1]
</txp:jk_link_to_prev>
<txp:jk_link_to_next sortby="custom_4">
[SQL (0.001399): select ID, Title, url_title, unix_timestamp(Posted) as uposted from textpattern where custom_4 > 
'model property' and Section = 'model homes'  and Status=4 and Posted < now() order by custom_4 asc limit 1]
[SQL (0.001287): select ID, Title, url_title, unix_timestamp(Posted) as uposted from textpattern where custom_4 < 
'model property' and Section = 'model homes'  and Status=4 and Posted < now() order by custom_4 desc limit 1]
[SQL (0.000258): select ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as posted 
from textpattern where ID = 11]
</txp:jk_link_to_next>

If this helps at all, the custom field is numeric and has been changed in the database to reflect that so that it sort properly when a search is done.

Offline

Board footer

Powered by FluxBB