Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-27 16:39:47

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

[request] Sort articles by custom category order...

I need a “companion” to the stw_category_tree plugin. It would function just like txp:article_custom, but allow a way to sort articles by Category1 or Category2 using the order set by stw_category_tree in the Menu Control extension tab.

Upon installation, stw_category_tree creates the idx field in the txp_category table in the database. I wonder if there is a way to get txp:article_custom to access the idx field in the txp_category table?

Rough illustration of what I’m thinking…..
bc. <txp:article_custom sort=“Category1 idx” />

Background, I am using this txp code to output a menu that lists articles by category. thanks to maniqui for offering an example of using variable, if_variable, and if_different to output articles by category : )

Offline

#2 2009-07-27 17:26:31

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

Re: [request] Sort articles by custom category order...

smd_query is your girlfriend

Offline

#3 2009-07-27 21:52:06

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: [request] Sort articles by custom category order...

Thanks mrdale! Wow, what an awesome girlfriend! We’ve only just met and the problem is that she is much much smarter than me….

I’ve read through the entire smd_query forum and help documentation and I’m stuck figuring out where to start. Should I start fresh and use smd_query as a total replacement for the article_custom in the code I was using… or, should I work smd_query in with it somehow? I’m confused as to how to query the articles from the Textpattern table and sort them via Category1’s idx field (the order) in the txp_category table. [Edit] Should I use the plugin in simple or complex mode?

I had just barely wrapped my head around maniquis code with the variables, etc. and now my brain really hurts… any little nudges, hints, etc. would be greatly appreciated.

thanks…

(I should probably move this question over to the smd_query topic…)

Last edited by photonomad (2009-07-27 22:45:38)

Offline

#4 2009-07-28 01:21:18

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [request] Sort articles by custom category order...

photonomad wrote:

I’m confused as to how to query the articles from the Textpattern table and sort them via Category1’s idx field (the order) in the txp_category table.

Here’s one approach:

<txp:article_custom sort='field(ID, <txp:smd_query query="select textpattern.ID from textpattern left join txp_category on category1 = name order by idx" break=",">{ID}</txp:smd_query>)' />

Last edited by jsoo (2009-07-28 01:22:11)


Code is topiary

Offline

#5 2009-07-28 03:12:28

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: [request] Sort articles by custom category order...

Thank you jsoo! That works perfectly. It also helps me further understand how SQL queries work along with the smd_query plugin. so many possibilities… : )

Offline

Board footer

Powered by FluxBB