Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Is it possible to sort articles by content of a specific custom field?
I want:
Some text followed by a list of articles that have a specific custom field value set to ‘one’
then:
Some other text followed by a list of articles that have a specific custom field value set to ‘two’
etc.
I tried something like this in an article form:
<code><txp:if_custom_field name=“sort” val=“one”></code>
<code><p>some text related to ‘one’</p></code>
<code><txp:permlink><txp:title /></txp:permlink></code>
<code></txp:if_custom_field></code>
<code><txp:if_custom_field name=“sort” val=“two”></code>
<code><p>some text related to ‘two’</p></code>
<code><txp:permlink><txp:title /></txp:permlink></code>
<code></txp:if_custom_field></code>
Problem with these conditional tags in an article form is: the sort order of <code><txp:article></code> or <code><txp:article_custom></code> seems allways dominant. Am I overlooking something?
It is possible to sort articles by custom_field content?
Last edited by kees-b (2005-10-04 15:53:37)
Offline
Re: Is it possible to sort articles by content of a specific custom field?
Couldn’t you use a separate form for each value then use <code><txp:article_custom form=“one” sortby=“title” sortdir=“asc” /></code> for each in your page template? You may need to specify the section attribute as well for this tag.
Last edited by thebombsite (2005-10-04 20:21:49)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#3 2005-10-04 21:59:45
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Is it possible to sort articles by content of a specific custom field?
According to TextBook the available values for sortby are Posted, Author, Last Modification, Title, or Section. But I’ve got sortby="custom_1" sortdir="asc"
in my article_custom tag and that works just as well. Also sortby="excerpt"
works, so I suppose that you can sort by every field in the textpattern table.
Offline
Re: Is it possible to sort articles by content of a specific custom field?
Thanks Stuart and Els!
Stuart Yes, you hit a blind spot. I did all my trying with only one txp:article tag - splitting them up is indeed an excellent idea.
Els Completely forgot about this wildly variable sort options of article_custom.
Offline
Re: Is it possible to sort articles by content of a specific custom field?
<blockquote><p>According to TextBook the available values for sortby are Posted, Author, Last Modification, Title, or Section. But I’ve got sortby=“custom_1” sortdir=“asc” in my article_custom tag and that works just as well</p></blockquote>
I can confirm that. It works if you use sortby=“custom_1”, but it wont work if you try to use the name you give to that custom field.
Example: if your custom_1 field is “weight” you cannot use sortby=“weight”. It wont work, and will return a blank.
<strong>But</strong> you can still use the sortby=“custom_1”, without worring if you have given the “weight” name to your custom_1 field.
The “problem” is that you have to remember wich is the custom field number that you want to use to sort the list.
(example: “I want to order by “weight” but I cant remember: custom_1 was named “weight”? or it was custom_7?”)
So, if we consider that < txp:article_custom / > already supports <strong>sortyby=”<i>custom_n</i>”</strong>, it would be nice that it support custom fields names.
Offline
Re: Is it possible to sort articles by content of a specific custom field?
…and to add some more good news, sorting with custom_n even works with plain <txp:article />
tags.
-kees
Last edited by kees-b (2005-10-18 20:12:55)
Offline
Re: Is it possible to sort articles by content of a specific custom field?
Yes, kees-b, I figured out that few minutes after posting that.
I have created <a href=“http://forum.textpattern.com/viewtopic.php?id=12082”>this thread</a> in Features Request category, but I have use a bad name (with some typo errors).
There, I suggest to add a feature to <code><txp:article /></code> and <code><txp:article_custom /></code>.
The feature is to have the option of sorting the articles list by custom fields name, that is not currently supported by this tags.
But I think that maybe users are ignoring that thread because of the typo errors that made the title has no sense.. (if this is not the case, why they would ignore my cool feature request? :D jijiji)
So, I would appreciate if somebody help me to bump up that thread…. of course, if you think, as me, that would be nice to have such feature.
thanks <small>and excuse my english</small>
Offline