Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-09 11:56:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,897
Website GitHub

link_to_next & prev within a category?

1) Is there a category-sensitive use or alternative for txp:link_to_next and txp:link_to_prev?

The context is: if_individual_article
The tag used in: an article form

The result: nice next and previous links but they disregard the current category.

I’ve got a workaround going using zem_nav and the modification suggested here:
<code>
replace: if ($usecat) $category = empty($c) ? ‘’ : $c;
with: if ($usecat) $category = empty($thisarticle[‘category1’]) ? $c : $thisarticle[‘category1’];
</code>
However, it is only then sensitive to category1.

  • * *

2) A related question:
If I assign an article 2 categories: “apples” and “green” it will appear in the category articles list for “apples” and the category list for “green”. That’s great.

When I click on the article in the “apple” category articles list and then want to link_to_next and link_to_prev I want to page back and forth between apples.
If I click on the article in the “green” category articles list, I want to page back and forth between all green fruits. At the moment this doesn’t happen.
How can I make the article form (for instance the breadcrumb) and link_to_prev and link_to_next know which of the two categories is currently relevant?


TXP Builders – finely-crafted code, design and txp

Offline

#2 2006-06-16 19:45:15

reptilerobots
Member
Registered: 2005-08-20
Posts: 72

Re: link_to_next & prev within a category?

Did you ever find a way to go to the next , or previous article within a category? I have one section “vault” and 3 categories – design, illustration, drawing – Id rather just have them all in one section, instead of 3. The regular txp tags, next/prev just return the next/prev articles within the section, not the category.

Offline

#3 2006-06-16 20:10:55

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: link_to_next & prev within a category?

<a href=“http://textpattern.org/plugins/154/lownav”>low_nav plugin</a> to the rescue!

Offline

#4 2006-06-16 20:40:16

reptilerobots
Member
Registered: 2005-08-20
Posts: 72

Re: link_to_next & prev within a category?

Its funny how long I search for these, and cant find them – thanks for coming to the rescue

Offline

#5 2006-06-16 20:45:52

reptilerobots
Member
Registered: 2005-08-20
Posts: 72

Re: link_to_next & prev within a category?

foiled again. Link is dead, and I think its for an earlier version of TXP!

Offline

#6 2006-06-16 20:56:14

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: link_to_next & prev within a category?

D’oh! I suggest contacting <a href=“http://justinlow.com/”>the developer</a> directly then.

Edited to add a request: if you receive an answer from Justin, please post to this thread again so that others may learn what’s going on with that plugin.

Last edited by Elenita (2006-06-16 21:01:29)

Offline

#7 2006-06-17 08:44:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,897
Website GitHub

Re: link_to_next & prev within a category?

I haven’t solved it yet. I also don’t have low_nav and I don’t know if he ever got it working with the current category rather than just category1 as he wrote in the thread.

This questions seems key to me:
How does the page which displays the article know what the ‘current’ category is, i.e., from which category list it has been linked? Can one write out an URL for that so I can understand it better?

  1. For the section I have an URL site/section and display a category list
  2. When I click on a category title I have an URL site/section&c=category and display a list of articles in that category
  3. When I click on one of these articles I have an URL site/section/article-name – there’s no indication of a category filter at all. For this you’d need an section/category/article-name URL, and is that possible?

How do other tags such as related_articles work if an articles has two categories applied (I’ve never used it myself). Does it display articles from both categories, only category1 or does it ‘know’ what the current article is. Or perhaps there’s another article-level tag or plug-in which is sensitive to the ‘current’ category, from which we could learn? Is there actually an equivalent for txp:category for individual articles?

(thinking aloud here: maybe if it’s not possible with textpattern alone, one could pass on the current category from the list-of-articles-in-category page as an URLvar using chs_if_urlvar, but that’s pretty dirty. I’d much prefer a txp way of doing things.)

Last edited by jakob (2006-06-17 09:27:18)


TXP Builders – finely-crafted code, design and txp

Offline

#8 2006-06-17 18:04:58

reptilerobots
Member
Registered: 2005-08-20
Posts: 72

Re: link_to_next & prev within a category?

I got an email back from Justin Low, and he said that his plugin isn’t currently available for the newest version of textpattern. He also said to try zem_nav, but when I have installed the plugin, I get this error:<br><br>
Fatal error: Call to undefined function: formathref() in /home/content/r/e/p/reptilerobots/html/pages/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 36<br><br>

so, apparently it doesnt work… and I still havent found other ways to browse articles by category. It seem like such a simple feature… you’d think it would have been a default tag.

Offline

#9 2006-06-17 18:20:42

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: link_to_next & prev within a category?

Sorry to hear that, reptilerobots.

The only thing I can suggest is to <a href=“http://forum.textpattern.com/viewforum.php?id=2”>formally request</a> that this feature be included in a future release.

Offline

#10 2006-06-17 22:50:05

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,897
Website GitHub

Re: link_to_next & prev within a category?

reptilerobots, zem_nav works if you install zem_link too (as it contains the function formathref). The modification mentioned at the beginning of the thread works at least for category1. If you have articles which are allocated two categories, then at present next and previous work within category1 only.


TXP Builders – finely-crafted code, design and txp

Offline

#11 2006-06-17 23:42:55

reptilerobots
Member
Registered: 2005-08-20
Posts: 72

Re: link_to_next & prev within a category?

really? I wasnt aware that I had to install zem_link – thanks! I am using 2 categories, the first cat is either design, drawings, illustration – the 2nd is just “new”, in the form that I am using to list each article, it spits out each category, and if_category is ‘new’ it just says NEW next to it.
Strange, I can’t get it to work. I installed zem_link, I dont get the error, but now the links they return are, for example:
<br><br>http://www.wearetherobots.com/pages/vault/drawing-2drawing-2<br><br> when it should be just <br><br>http://www.wearetherobots.com/pages/vault/drawing-2<br><br>
it’s reading the title twice and adding it to the link. I modified the lines as you mentioned in the first post.

Last edited by reptilerobots (2006-06-18 00:07:50)

Offline

#12 2006-06-18 08:31:40

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,897
Website GitHub

Re: link_to_next & prev within a category?

I think the double URL is a problem with an earlier version of zem_link. I’m using zem_link 0.6 and zem_nav 0.6 (tho’ I think it’s actually 0.4). There’s a link to a nwere zem_nav in this thread and to a newer zem_link courtesy of wet here.

You might also be able to achieve what you want with the “new” flag by setting those articles to sticky instead of live and marking articles with status sticky with the flag. You might have to play around a bit with txp:article or txp:article_custom to get it list them how you want. You could also do that using a custom_field and then test for txp:if_custom_field name=“new” value=“yes” (or something like that) then show “new” flag.

Last edited by jakob (2006-06-18 08:34:24)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB