Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-19 18:04:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,481
Website GitHub

smd_horizon: What's that coming over the hill...

If you’ve ever been troubled by the restrictions that TXP places on you for navigating next/prev articles, be confined no more.

There’s an antidote: smd_horizon

Features:

  • Ability to link to articles that are to be published in future; <txp:next/prev_title /> and <txp:link_to_next/prev> work beyond the existing Posted range
  • Detection of when you are about to “fall off the end” of a section or category, in either direction
  • Entire adjacent article contents available in the current article for your (mis)use so you can tease people with what’s coming next or use any article content as a link (use the article image to link to the next article; or custom field contents; or anything else you fancy: it’s your call)
  • Navigate seamlessly between many sections, categories or authors
  • Track URL parameters between articles and/or sections so you can maintain state

There are a tonne of examples in the plugin help, but if you can think of any more wacky uses for this please post your tags here. And, as ever, if things go your way (or don’t) feel free to let me know.

Up, up and awaaaaaaay…

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the threads to learn about the features.

  • 19 Apr 09 | 0.1 | Initial release

Last edited by Bloke (2009-04-19 19:33:01)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2009-04-19 20:26:53

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

Re: smd_horizon: What's that coming over the hill...

Excellent work, Stef!

Offline

#3 2009-04-19 21:53:19

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

Re: smd_horizon: What's that coming over the hill...

What I like most is the title. ‘Horizon’. I always knew that your plug-in menagerie is kind of esoteric. Again I will follow. Just to find out what funny usages the users will have to tell :)


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

Offline

#4 2009-04-19 22:13:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,481
Website GitHub

Re: smd_horizon: What's that coming over the hill...

merz1 wrote:

What I like most is the title. ‘Horizon’.

I took a leaf out of wet’s book: why call a plugin by a tedious, factual name when something that encapsulates its functionality and adds an air of mystery does just as well :-) Hope you like the plugin as much as the name.

Last edited by Bloke (2009-04-19 22:14:00)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2009-04-20 01:10:24

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,214
Website

Re: smd_horizon: What's that coming over the hill...

Un-ba-freakin-leavable. previous/next as it should be.

I gave up on core prev/next giving me consistent/predictable/rational result altogether.

nice! very nice.

Offline

#6 2009-04-21 15:48:55

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

Re: smd_horizon: What's that coming over the hill...

Hope you like the plugin as much as the name.

Have been awake all night to think about possible use cases.

Detection of when you are about to “fall off the end” of a section or category, in either direction

For this case I am using chh_if_data at the moment.

Entire adjacent article contents available in the current article…

Not from the next or previous article?

Navigate seamlessly between many sections, categories or authors

Do I get it right that I can navigate by article ID whatever section the article belongs to? No more section boundary?

If Yes this starts to get interesting.

Track URL parameters between articles and/or sections so you can maintain state

I have no idea what this means.


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

Offline

#7 2009-04-21 16:25:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,481
Website GitHub

Re: smd_horizon: What's that coming over the hill...

merz1 wrote:

Entire adjacent article contents available in the current article… Not from the next or previous article?

No. Let’s say you are viewing an article, call it Article 4. If you wrap smd_prev and smd_next tags around your standard <txp:link_to_prev> and <txp:link_to_next> tags, then from this article you can “see” and use the entire contents of Article 3 and Article 5 — the ones either side of the current article. Thus, instead of a boring link using <txp:title /> you could use:

<txp:smd_next>
  <txp:link_to_next><txp:custom_field name="some_info" /></txp:link_to_next>
</txp:smd_next>

Or even the article image. Whatever is in the next (or previous) article is available for preview from the current article.

But of course the tags in this plugin go waaaay beyond that simple scenario ;-) For example, if your ‘next’ article is not yet published (future date) or even set with a status of hidden, you are permitted to “see” its contents and — in the case of future articles — link to them using the standard tags.

I am using chh_if_data at the moment.

That’s fine. The smd_if_end and smd_if_start are just convenience functions but they can be very useful (see the later examples in the help).

Do I get it right that I can navigate by article ID whatever section the article belongs to? No more section boundary?

Yes. If you use:

<txp:smd_next section="sec1, sec2, sec3">
   <txp:link_to_next>NEXT!</txp:link_to_next>
</txp:smd_next>

Then your standard link_to_next/prev tags just keep going until you run out of articles in all 3 sections. In addition, <txp:smd_if_end> and <txp:smd_if_start> can detect when you reach a section boundary and/or the complete end of all three sections.

Track URL parameters between articles and/or sections so you can maintain state

Meaning, if you have ?m=7&y=2009 on your URL line — because the current page is the result of clicking a month in a sidebar calendar for example — you can “copy” those values onto the end of the link to the next and previous pages. So your calendar does not “reset” to the current month when you go the next page, it remains showing the month your visitor chose.

And remember, everything works across section/category boundaries so you can offer some really crazy “taboo” navigation, like jumping from category to category when clicking ‘next article’.

Does that give you a bit more insight?

Last edited by Bloke (2009-04-21 16:26:48)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2009-04-21 18:46:12

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

Re: smd_horizon: What's that coming over the hill...

Yep. Thanks a lot for the explanations.

I knew you would use the calendar example for the URL parameters :)

Can you comment on the performance this turbo charged navigation will eat compared to the core tags?

Edit / PS: Is there a way to integrate rss_auto_excerpt inside the <txp:link_to_next>...</txp:link_to_next> container or are only TXP article fields allowed?

Last edited by merz1 (2009-04-21 18:50:12)


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

Offline

#9 2009-04-21 20:57:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,481
Website GitHub

Re: smd_horizon: What's that coming over the hill...

merz1 wrote:

Can you comment on the performance this turbo charged navigation will eat compared to the core tags?

One extra query per “side”. smd_next and smd_prev need one query each to “load” the content, then all the other tags function off that. Since you can only ever go one step at a time in either direction, that’s all it needs.

If you don’t use smd_next or smd_prev there are no extra queries, just a tiny few extra lines of stuff to make some quick decisions. You can use smd_link_to_next/prev, or the conditionals, without smd_prev/next and they’ll do some stuff over and above what is available with core tags. But the real power comes with smd_next/prev: the price you pay is a maximum of 2 queries. Your call if it’s worth it!

The code is surprisingly lean; “surprisingly” because its one of my plugins and I’m not renowned for making them small ;-)

Is there a way to integrate rss_auto_excerpt inside the <txp:link_to_next>...</txp:link_to_next>

In theory, yes. Any tag that blindly uses what is available in “this article” as its source of data will actually see the “next article” or “previous article” contents depending on which way you are looking. Tags/plugins that do their own queries will be unaffected by my containers. Which mode applies to rss_auto_excerpt I don’t know, but I suspect it uses “this article” because there’s no reason for it to look anywhere else. You might be in luck: try it and see what happens, then let us know!

To be honest, I hadn’t considered that, but it’s a potential extra bonus to be able to use other plugin tags to format stuff from adjacent articles as well. Things like rvm_substr should work to allow you to shorten adjacent article information (custom fields, etc).


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#10 2009-04-22 01:13:24

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

Re: smd_horizon: What's that coming over the hill...

Any tag that blindly uses what is available in “this article” as its source of data

That’s really good news! I’ll sleep over it and give it a try. That might be a great solution to show a short trigger excerpt for the next and previous articles under an article. Example:

<txp:rss_auto_excerpt length="150" showlinkwithexcerpt="1" linktext="More &hellip;" ending="&hellip;" overrideexcerpt="1" striptags="1" linkwraptag="strong" excerptwraptag="p" />

In my case the only isue to solve is that I tweaked the rss_auto_excerpt code to not strip <h4> which I always use for a sub-headline. But an extra CSS class will help.


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

Offline

#11 2009-11-24 16:34:36

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_horizon: What's that coming over the hill...

Hi Bloke,

thanks for this little gem. I’m trying it for the very firs time, with a combo of MLP and gbp_p_l.
I’m having an issue, I would say “inconsistent behaviour”.

I’m trying to create a prev/next navigation for articles on the same category1 of current article.
So, I’ve set up this:

<txp:article...>
...
 <txp:chh_if_data><txp:smd_prev category='<txp:category1 />'><a href="<txp:smd_link_to_prev />" class="button prev-article"><txp:prev_title /></a></txp:smd_prev></txp:chh_if_data>
<txp:chh_if_data><txp:smd_next category='<txp:category1 />'><a href="<txp:smd_link_to_next />" class="button next-article"><txp:next_title /></a></txp:smd_next></txp:chh_if_data>

The smd_prev… works almost fine: when I’m at the first article permalink, it doesn’t output any link to any other article not belonging to category1… that’s cool… unless I remove the wrapping chh_if_data. In that case, I’ll end up with a link to website root, and the txp:prev_title will render the title of an article belonging to the same section, but not to category1.
Do I explain myself?

The smd_next, when I’m at the last article belonging to category1, doesn’t work. It outputs a wrong link to website root (similar to what I said before), and txp:next_title renders the title of another article that belongs to current section, but not to assigned to category1.

Bloke, I hope you have understand my report, as it’s difficult to me to try to explain this in words :)

Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#12 2009-11-24 16:43:53

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_horizon: What's that coming over the hill...

Oooook.
Thing got fixed when I changed the above snippet to the following one:

<txp:chh_if_data><txp:smd_prev category='<txp:category1 />'><txp:smd_link_to_prev class="button button-arrow prev-article"><span><txp:prev_title /></span></txp:smd_link_to_prev></txp:smd_prev></txp:chh_if_data>
<txp:chh_if_data><txp:smd_next category='<txp:category1 />'><txp:smd_link_to_next class="button button-arrow next-article"><span><txp:next_title /></span></txp:smd_link_to_next></txp:smd_next></txp:chh_if_data>

The difference is the smd_link_to_prev/next used as a container tag instead of used as a single tag.
Now, when I reach the end of txp:category1, I don’t get any undesired output.
And it even works without the wrapping chh_if_data!

Thanks for this gem, Mr. Bloke.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB