Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2006-06-19 16:56:31

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: link_to_next & prev within a category?

yes I agree, it is a shortcoming at the moment. If one were able to use section/category/title urls then I imagine it would work with the normal txp commands (as the category context is then always given). Unfortunately, this combination is not currently supported at the moment.

The other related area I’ve found difficult to achieve is being able to filter by two categories, i.e. look for items (articles) according to type and location. This kind of search combination is fairly common in a non-blog environment, but I’ve only got part of the way there using similarly complex trickery.


TXP Builders – finely-crafted code, design and txp

Offline

#17 2006-06-23 16:17:18

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

Re: link_to_next & prev within a category?

Jakob – I restructured some things on my site, I just have everything lumped together instead of separate. Anyways, instead of assigning “new” to category 2, I am using a custom field called “new”. If the value is “new” it shows a dagger next to the article!

Thanks for your advice.

<code>
<txp:if_custom_field name=“new”>
<div class=“article”><txp:permlink><h2><txp:title /></h2><txp:excerpt /><h4><txp:category1 /></h4></txp:permlink><h5>&dagger;</h5></div>
<txp:else />
<div class=“article”><txp:permlink><h2><txp:title /></h2><txp:excerpt /><h4><txp:category1 /></h4></txp:permlink></div>
</txp:if_custom_field>

</code>

Offline

#18 2006-06-23 21:33:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: link_to_next & prev within a category?

yes, in your case it’s essentially a flag rather than a category. Not really important, but you could shorten your code by starting your if_custom_field just before h5 as that seems to be the only bit that changes.


TXP Builders – finely-crafted code, design and txp

Offline

#19 2010-04-14 15:47:07

inkywillow
Member
From: France
Registered: 2009-12-22
Posts: 37

Re: link_to_next & prev within a category?

Hi all, did anybody ever find a simple solution to this problem?


The Design Works – Freelance website designer

Offline

#20 2010-04-14 17:22:16

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: link_to_next & prev within a category?

Would smd_horizon do what you want?

Offline

#21 2010-04-14 18:48:21

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: link_to_next & prev within a category?

You can try this tip


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#22 2010-04-14 18:51:10

inkywillow
Member
From: France
Registered: 2009-12-22
Posts: 37

Re: link_to_next & prev within a category?

Hi Els,

I’m not sure.

I basically have a section called shop and each item (article) in it can have two categories assigned to it. ie A chair could be in both “Handmade” and “Furniture”.
The problem is when viewing the individual article the next and previous buttons scroll through ALL items in the shop section, jumping categories as it where.
What I would like to do is restrict the next and previous buttons to scrolling through just the first category chosen (from the main navigation).

Here’s the website in question www.outoflove.co.uk

Any pointers would be appreciated!

Tom

@The_ghost I think we posted at the same time, I’ll take a look, thanks.

Last edited by inkywillow (2010-04-14 18:54:37)


The Design Works – Freelance website designer

Offline

#23 2010-04-14 21:24:06

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: link_to_next & prev within a category?

Did you look at the plugin? As far as I know that is what it can do.

Offline

#24 2010-04-15 18:15:14

inkywillow
Member
From: France
Registered: 2009-12-22
Posts: 37

Re: link_to_next & prev within a category?

Yeah, I tried the code below.

The problem seems to be with using two categories. When you view an item, the next and previous results are restricted (correctly) to the “Current” two categories and all works well until you hit an item using a third category, this then becomes one of the two current categories. For example if you have an item from “Furniture” and its second category is “Handmade” the next and previous buttons would (at this point) scroll through all items in “Furniture” and “Handmade” but when you got to an item in say “Handmade” and “Gifts” the “Current” sections would now become “Handmade” and “Gifts”.

I think that I am going to have to change this to use only category1 and have just one category per item.

	<txp:chh_if_data>
<div class="left"><p><txp:chh_if_data><txp:smd_prev category='<txp:category1 />,<txp:category2 />'><txp:smd_if_start><txp:else /><a href="<txp:permlink />">« Previous item</a></txp:smd_if_start></txp:smd_prev></txp:chh_if_data></p></div>

<div class="right"><p> <txp:chh_if_data><txp:smd_next category='<txp:category1 />,<txp:category2 />'><txp:smd_if_end><txp:else /><a href="<txp:permlink />">Next item »</a></txp:smd_if_end></txp:smd_next></txp:chh_if_data></p></div>
		</txp:chh_if_data>

The Design Works – Freelance website designer

Offline

Board footer

Powered by FluxBB