Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2007-05-05 06:32:17

LetterHoofd
Member
From: Kortrijk, BE
Registered: 2006-01-20
Posts: 40
Website

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

This plugin seams very valuable. However it only works with published articles. I use my txp-installation as a calendar for upcoming events. It would be great if you could add an extra atribute, such as time=“future/past/all”.

Offline

#26 2007-05-05 08:44:58

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

Version .4 supports articles with posted dates in the future. Just set the “showfuture” attribute to “1”.

Offline

#27 2007-05-11 19:48:57

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

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

Hi,

I can’t seem to get sortby=“posted” to work. In my case, it always fails to return a link_to_next, and it always returns the same link_to_prev, no matter what the current article is. Here’s the relevant debug info:

<txp:jk_link_to_next cat="current" sortby="posted" >
		[SQL (0.001107): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted > '2007-04-07 03:30:35' and Section = 'article'  and category1 = 'Acoustics' and Status=4 and Posted < now() order by posted asc limit 1]
		[SQL (0.001012): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted < '2007-04-07 03:30:35' and Section = 'article'  and category1 = 'Acoustics' and Status=4 and Posted < now() order by posted desc limit 1]
	</txp:jk_link_to_next>
	<txp:jk_link_to_prev cat="current" sortby="posted" >
		[SQL (0.001044): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted > '2007-04-07 03:30:35' and Section = 'article'  and category1 = 'Acoustics' and Status=4 and Posted < now() order by posted asc limit 1]
		[SQL (0.001009): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted < '2007-04-07 03:30:35' and Section = 'article'  and category1 = 'Acoustics' and Status=4 and Posted < now() order by posted desc limit 1]
		[SQL (0.001816): select *,ID as thisid, unix_timestamp(Posted) as posted from mattgilbertnet_textpattern as textpattern where ID=20]
	</txp:jk_link_to_prev>

Is sortby=“posted” not working?

Offline

#28 2007-05-11 20:00:54

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

Try v.45. Should be fixed.

Offline

#29 2007-05-12 01:45:53

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

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

I’m still getting the same behavior. When I tried the tags without specifying a “cat” attribute, jk_link_to_next returns the newest article and jk_link_to_prev returns the second newest article. I hope that helps.

Here’s the debug stuff from when there’s no “cat” attribute:

<txp:jk_link_to_next sortby="posted" >
		[SQL (0.000986): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted > '2007-04-07 03:26:50' and Section = 'article'  and Status=4  order by posted asc limit 1]
		[SQL (0.004960): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted < '2007-04-07 03:26:50' and Section = 'article'  and Status=4  order by posted desc limit 1]
		[SQL (0.001717): select *,ID as thisid, unix_timestamp(Posted) as posted from mattgilbertnet_textpattern as textpattern where ID=23]
	</txp:jk_link_to_next>
	<txp:jk_link_to_prev sortby="posted" >
		[SQL (0.000790): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted > '2007-04-07 03:26:50' and Section = 'article'  and Status=4  order by posted asc limit 1]
		[SQL (0.000834): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from mattgilbertnet_textpattern where posted < '2007-04-07 03:26:50' and Section = 'article'  and Status=4  order by posted desc limit 1]
		[SQL (0.001294): select *,ID as thisid, unix_timestamp(Posted) as posted from mattgilbertnet_textpattern as textpattern where ID=21]
	</txp:jk_link_to_prev>

Offline

#30 2007-05-13 04:56:33

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

Matt,

I can’t seem to replicate this behavior on my server. The query above should be returning a result if one exists. You might want to double check that the posted date in the query reflects the date of the current article shown. Also, you could add “print_r($thenext); print_r($theprev);” at the end of the plugin and before the “return $out; }”, and see if it returns a pair of arrays with the correct article information — which it should.

Offline

#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

Board footer

Powered by FluxBB