Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2009-05-21 13:58:21
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dictating category links order
This works for me (on the page). Keep in mind that the code is using my own section and custom field names. The if_article_category part is only to be able to use both categories, if you don’t need that you can remove it.
<txp:if_individual_article>
<h3>Related articles</h3>
<ul>
<txp:article_custom sort="custom_4 asc" section="zoo" category='<txp:category1 /><txp:if_article_category number="2">,<txp:category2 /></txp:if_article_category>'>
<txp:if_article_id>
<txp:else />
<txp:if_custom_field name="sortfield">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:if_custom_field>
</txp:if_article_id>
</txp:article_custom>
<txp:article_custom section="zoo" sortfield="" category='<txp:category1 /><txp:if_article_category number="2">,<txp:category2 /></txp:if_article_category>'>
<txp:if_article_id>
<txp:else />
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:if_article_id>
</txp:article_custom>
</ul>
</txp:if_individual_article>
Last edited by els (2009-08-08 12:29:10)
Offline
Re: Dictating category links order
Once again thx for all your input. Ik works 99%
This is what i now have.
<txp:article_custom offset="1" sort="custom_3 asc" category='<txp:category2 />'>
<txp:if_custom_field name="aanverwante_links_volgorde">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:if_custom_field>
</txp:article_custom>
<txp:article_custom sort="posted asc" aanverwante_links_volgorde="" category='<txp:category2 />'>
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
The one thing that’s not working 100% is when there are unsorted articles, the offset no-longer works on the sorted articles??????
Last edited by Timid&friendly (2009-05-21 16:04:11)
I think, therefore I AM, … … er … I think :-?
Offline
#18 2009-05-21 16:10:26
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dictating category links order
offset="1" sort="custom_3 asc" will skip the first article in the list generated by the tag and it’s attributes, in this case the article with the lowest value in custom_3. Are you using the offset to exclude the current article? Why not use my if_article_id method?
Offline
Re: Dictating category links order
Timid&friendly wrote:
The one thing that’s not working 100% is when there are unsorted articles, the offset no-longer works on the sorted articles??????
Right, because the conditional is inside the article tag; the tag itself is picking up all the articles.
There’s probably a native tag-based solution in which the offset is the count of the unsorted articles plus one.
Code is topiary
Offline
Re: Dictating category links order
Timid&friendly wrote:
The only thing it’s missing is that the links need to wrap and break using a parent
<li>instead of<br />. And I need to offset by 1 link (as i don’t need to show this).
<ul>
<txp:php>
$c1 = $thisarticle['category1'];
$c2 = $thisarticle['category2'];
$rs = safe_rows('ID, Title', 'textpattern', "custom_3 != '' and ((Category2 = '$c1') or (Category2 = '$c2')) order by custom_3 asc limit 1,999");
foreach ( $rs as $r )
echo tag(href($r['Title'], permlinkurl_id($r['ID'])), 'li');
</txp:php>
</ul>
Code is topiary
Offline
Re: Dictating category links order
Els wrote:
…Are you using the offset to exclude the current article?
No i am not. (btw. i am gunna stop saying thx cos you know i am ;-)
The purpose of the offset is to hide the first article in my level2 navigation, which has category names “wat” and “promise”.
The level3 navigation is what i am trying to output, which only has the category name “promise”.
This first ordered article needs to be skipped so that is doesn’t appear in level3 nav (this level2 nav item has to have the level3 category name “promise” otherwise it won’t show them).
I love txp but navigation can be real drama some times :-( and as far as i am concerned it’s certainly not intuitive.
Last edited by Timid&friendly (2009-05-21 16:52:03)
I think, therefore I AM, … … er … I think :-?
Offline
#22 2009-05-21 17:39:58
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dictating category links order
Timid&friendly wrote:
(btw. i am gunna stop saying thx cos you know i am ;-)
Fine :) It’s more important to me to hear if my contributions work or not.
The purpose of the offset is to hide the first article in my level2 navigation, which has category names “wat” and “promise”.
The level3 navigation is what i am trying to output, which only has the category name “promise”.
So I misunderstood what you were using ‘offset’ for. Would excluding category ‘wat’ do the same?
BTW I’m not sure if I should still be replying ;) Are you working with jsoo’s examples or mine?
Offline
Re: Dictating category links order
Your replies are always very welcome. I am trying to really understand txp so i am trying everything, your suggestions and those kindly offered by jsoo’s. I want to master this CMS so i can do anything i need to or want, but i’ve still got a long way to go.
Excluding the category “wat” may indeed help. But i already looked to see if exclude was an attribute of the article_custom tag and it wasn’t.
I was thinking about adding classes “level1, level2 and 3” so as to avoid these sorts of conflicts i have ran into. I’ve heard there’s a plug-in that gives you unlimited categories.
It would however be very handy if txp it’s self had extra nav functionality, something like the category/section select pulldowns but for navigation allone, that allow one to specify structurally and sematically the role of articles within the system. … but i’ll guess i’ll just try the extra categories first ;-)
I think, therefore I AM, … … er … I think :-?
Offline
#24 2009-05-21 20:08:57
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dictating category links order
A ‘workaround’ to exclude a category is this:
<txp:article_custom sort="custom_3 asc" category='<txp:category2 />'>
<txp:if_article_category name="wat">
<txp:else />
<txp:if_custom_field name="aanverwante_links_volgorde">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:if_custom_field>
</txp:if_article_category>
</txp:article_custom>
Offline
Re: Dictating category links order
That was it! It works great now! Yet another lesson learned hear (toch bedankt ;-)
I think, therefore I AM, … … er … I think :-?
Offline
Re: Dictating category links order
jsoo
Your php code solution worked great also. I apologise that i didn’t reply, but that because i some how missed your post. Thx for your input!
I think, therefore I AM, … … er … I think :-?
Offline
Re: Dictating category links order
Glad to hear it worked also, while I am in full agreement that using native Txp tags is best if you get the functionality you want (and the markup isn’t overly complicated). So I’m glad you had Els on the case — if anyone can find a tag-based solution to a problem, it’s Els.
Code is topiary
Offline
#28 2009-06-19 11:34:32
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dictating category links order
I wrote:
A ‘workaround’ to exclude a category is this: (some code)
Of course there is a better way :)
Offline
Re: Dictating category links order
Thx Els,
When i get a mo i’ll try it out.
I think, therefore I AM, … … er … I think :-?
Offline