Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-03-28 10:07:20

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

jmd_neighbor: Pipe neighboring articles into an article form

Download

<txp:jmd_neighbor/> allows for next and previous articles to be output in an article form. Requires PHP51.

Tag overview

Tag Attributes Description
<txp:jmd_neighbor/> form, type Pipe a neighboring article into a form
<txp:jmd_if_neighbor> type Checks for neighboring articles

<txp:jmd_neighbor/>

Attribute Available values Default value Description
form

neighbor The form for neighboring articles
type next, prev

<txp:jmd_if_neighbor/>

Attribute Available values Default value Description
type next, prev If ommited, the tag checks for the presence of any neighbor.

Examples

Link the article images of next and previous articles

Form: default

<ul>
	<txp:jmd_neighbor type="prev"/>
	<txp:jmd_neighbor type="next"/>
</ul>

Form: neighbor

<li>
	<txp:jmd_if_neighbor type="next">
		Next:
	<txp:else/>
		Prev:
	</txp:jmd_if_neighbor>

	<txp:permlink>
		<txp:title/><txp:article_image thumbnail="1"/>
	</txp:permlink>
</li>

Check for neighbors

Form: neighbor

<txp:jmd_if_neighbor>
	Yes, there are neighbors.
<txp:else/>
	Nope, you're in Montana.
</txp:jmd_if_neighbor>

1 If you need PHP4 compatibility, replace public $type; with var $type; and remove public from the next line.

Last edited by jm (2008-03-31 08:34:42)

Offline

#2 2008-03-28 10:58:56

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

Useful! Thanks!


Prrrrrrrr

Offline

#3 2008-03-28 18:14:26

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

Do I have tomatoes on my eyes?
What’s the difference?

I am using txp:chh_if_data (plugin), txp:link_to_prev & txp:link_to_next

<txp:chh_if_data><txp:link_to_prev>Older</txp:link_to_prev><txp:else />Oldest</txp:chh_if_data>
<txp:chh_if_data><txp:link_to_next>Newer</txp:link_to_next><txp:else />Newest</txp:chh_if_data>

Last edited by merz1 (2008-03-28 18:14:50)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#4 2008-03-28 18:30:41

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

Yes, the tomatoes are on your eyes :). The only similar function between chh_if_data and jmd_neighbor is they can check for next and previous articles. My plugin lets you use forms for the next and previous articles – it doesn’t link anything. The following should illustrate the differences:

<txp:hide>Some article form</txp:hide>
<txp:jmd_neighbor form="sub_nav" type="prev"/>

<txp:hide>form: sub_nav</txp:hide>
<txp:permlink>
	<txp:title/> - <txp:posted/>
</txp:permlink>

The above will display the previous article’s title and date. If you use the following, the current article’s title and date will be returned.

<txp:chh_if_data>
	<txp:link_to_prev>
		<txp:title/> - <txp:posted/>
	</txp:link_to_prev>
</txp:chh_if_data>

Last edited by jm (2008-03-28 18:31:34)

Offline

#5 2008-03-28 22:58:24

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

<txp:jmd_neighbor form="sub_nav" type="prev" />
  • OK. I assume the output comes from the form sub_nav?
  • And I assume that type="prev" defines to look for the previous article in the same section (only)?

The form sub_nav

<txp:permlink><txp:title/> - <txp:posted/></txp:permlink>

I see (I hope).

For a better documentation of your plug-in I would love to see all available parameters and the possible values in the announcement.

Yes, the function is useful if somebody i.e. wants to post a short auto excerpt and not only a link.

Btw: This is the TXP way of linking titles if somebody only need that

<txp:link_to_next><txp:next_title /></txp:link_to_next>
<txp:link_to_prev><txp:prev_title /></txp:link_to_prev>

Last edited by merz1 (2008-03-28 23:06:11)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#6 2008-03-28 23:22:48

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

merz1 wrote:

OK. I assume the output comes from the form sub_nav?

Correct.

And I assume that type="prev" defines to look for the previous article in the same section (only)?

Yep – it uses TXP’s $GLOBALS['prev_id'], which is by section.

For a better documentation of your plug-in I would love to see all available parameters and the possible values in the announcement.

The help file has a complete reference, but I’ll post it here too. Posted the giant yellow blob :).

Last edited by jm (2008-03-28 23:48:14)

Offline

#7 2008-03-29 01:15:22

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

Thanks! Some documentation issues:

All single tags are closed ‘/ >’.

I.e. <txp:jmd_neighbor/> must become <txp:jmd_neighbor />. A simple search & replace should do the whole work.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#8 2008-03-29 01:21:06

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

merz1 wrote:

Thanks! Some documentation issues:

All single tags are closed ‘/ >’.

I.e. <txp:jmd_neighbor/> must become <txp:jmd_neighbor />. A simple search & replace should do the whole work.

It doesn’t actually make a difference – I prefer the XSLT-style. TXP’s error messages actually use it too.

Offline

#9 2008-03-29 06:00:13

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

jm wrote:

It doesn’t actually make a difference – I prefer the XSLT-style. TXP’s error messages actually use it too.

Yeah, parser parses both.

Last edited by Gocom (2008-03-29 06:00:58)

Offline

#10 2008-03-29 15:06:20

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

Re. ‘/ >’: Oops, somebody sometimes ago told me pretty strict that the format ‘/ >’ is expected for whatever internal validation. I didn’t want to be too picky but just remembered that rule.

But another documentation subject which should be included is where the tag will (not) work. (HTML header, page template, article form, article list).

This would be my basic announcement

Feature: <txp:jmd_neighbor/> allows the ouput of next and previous articles through article forms. The article forms can contain nearly everything you can do with TXP tags.

Important: If certain plug-ins or TXP core tags don’t work or throw errors in the used form please add a comment to this thread.

  • <txp:jmd_neighbor/> requires PHP5.
    • If you need PHP4 compatibility, replace public $type; with var $type; and remove public from the next line.
  • <txp:jmd_neighbor/> can be used for single articles only.
    • The plugin will issue an error if used outside an article context.
    • Note (type): It uses TXP’s $GLOBALS['prev_id'], which is by section so only the next and previous articles from the same section are searched.

The code for the announcement:

*Feature:* @<txp:jmd_neighbor/>@ allows the ouput of next and previous articles through article forms. The article forms can contain nearly everything you can do with TXP tags.

*Important:* If certain plug-ins or TXP core tags don't work or throw errors in the used form please add a comment to this thread.

* @<txp:jmd_neighbor/>@ requires PHP5.
** If you need PHP4 compatibility, replace @public $type;@ with @var $type;@ and remove @public@ from the next line.
* @<txp:jmd_neighbor/>@ can be used for single articles only.
** The plugin will issue an error if used outside an article context.
** Note (type): It uses @TXP’s $GLOBALS['prev_id']@, which is by section so only the next and previous articles from the same section are searched.

To check: Does rss_auto_excerpt work in the form for the next/previous articles?

Last edited by merz1 (2008-03-29 16:28:41)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#11 2008-03-29 15:18:45

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

merz1 wrote:

But another documentation subject which should be included is where the tag will (not) work. (HTML header, page template, article form, article list). This could be the basic announcement:

The plugin will issue an error if used outside an article context, so the documentation just needs to catch up. Thanks.

To check: Does rss_auto_excerpt work in the form for the next/previous articles?

Have you tried? Article plugins and tags should work.

Offline

#12 2008-03-29 16:19:34

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: jmd_neighbor: Pipe neighboring articles into an article form

The plugin will issue an error if used outside an article context

Updated my announcement :)

Have you tried? Article plugins and tags should work.

No, I am just following this thread for ‘future usage’. But the plug-ins rss_auto_excerpt or even tru_tags might become interesting depending on the output volume if needed.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

Board footer

Powered by FluxBB