Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[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
Re: [request] Sort articles by custom category order...
smd_query is your girlfriend
Offline
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
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
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