Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-29 03:39:33

Addicted
New Member
Registered: 2006-10-28
Posts: 4

Next/Previous Jumps

Sites like google and flickr use the link rel=“next”(or something along the lines of that) to tell the browser what the next page is, I wanted to add something like that to my blog because its only the coolest thing since tabbed browsing no longer do I have to become a slave to the next button!. I only think opera took advantage of this awsome feature though.

The below part returns blank href, probably because it is blank <txp:if_article_list> <link rel=“prev” href=”<txp:older />” /> <link rel=“next” href=”<txp:newer />” /> </txp:if_article_list>
This part Returns Nothing? probably because if_individual_articles is a funtion, and not a statement, <txp:if_individual_article> <link rel=“prev” href=”<txp:link_to_prev />” /> <link rel=“next” href=”<txp:link_to_next />” /> </txp:if_individual_article>

thanks,

Offline

#2 2006-10-29 07:25:46

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

Re: Next/Previous Jumps

I had the same issue awhile ago (for prefetching in Gecko browsers, which is the same for additional nav aids), but it’s pretty easy to fix.

About the code

  • Doesn’t display a next & prev link on last and first articles when placed in your article form, since there wouldn’t be a previous article on the last article, and there wouldn’t be a newer article on the first article.
  • If you place it in a non-article form (header, or page template), the above behavior won’t appear, and links to the sections will be displayed. You’ll need to rework your template so part of the head appears in your article form (or is called by your article form), if you want the proper behavior. I’m pretty sure <link /> is valid outside the <head> (and Opera respects this), so you can just output the form in your article form.

form: prefetch (or something like that)

<!--if we're on the first article, don't display a next <link>-->
<txp:if_first_article>
<txp:else />
	<link href="<txp:site_url /><txp:php>
		echo $GLOBALS['pretext']['s'].'/';
		echo $GLOBALS['pretext']['next_utitle'];
	</txp:php>" rel="next" />
</txp:if_first_article>
<!--if we're on the last article, don't display a prev <link>-->
<txp:if_last_article>
	<txp:else />
	<link href="<txp:site_url /><txp:php>
		echo $GLOBALS['pretext']['s'].'/';
		echo $GLOBALS['pretext']['prev_utitle'];
	</txp:php>" rel="prev" />
</txp:if_last_article>

default/your article form

If this form isn’t used on an article list, remove the if_individual_article tags.

<txp:if_individual_article><txp:output_form form="prefetch" /></txp:if_individual_article>

HTML output (not a first or last article)


	<!--if we're on the first article, don't display a next <link>-->

		<link href="http://localhost/txp/gallery/test" rel="next" />

	<!--if we're on the last article, don't display a prev <link>-->

		<link href="http://localhost/txp/gallery/flower" rel="prev" />

check out The Broadways ska band

You could also expand on this with creating a link to the section index (<txp:section />) and home (<txp:site_url />).

Last edited by jm (2006-10-29 07:35:50)

Offline

Board footer

Powered by FluxBB