Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-05 22:43:42

darock
Member
Registered: 2007-11-23
Posts: 54

Can Article_custom display 2 statuses instead of just 1?

I’m trying to get my sitemap to display all articles but it is only displaying those that are live. It seems that article_custom can’t show both live and sticky at the same time. Some of my articles have a sticky status. Is there another way around this…to show both live and sticky articles?

this is what it looks like on my page template;

<txp:article_custom limit="99999" form="sitemap" sort="section asc,Posted asc" status="" />

Offline

#2 2008-12-05 23:44:37

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Can Article_custom display 2 statuses instead of just 1?

You can use more than one article_custom tag.

Offline

#3 2008-12-05 23:57:37

darock
Member
Registered: 2007-11-23
Posts: 54

Re: Can Article_custom display 2 statuses instead of just 1?

true. but the problem with using the tag twice is that it now renders the articles that belong to one section twice and seperately.

Doing this;

<ul style="display:none;">
<txp:article_custom limit="99999" form="sitemap" sort="section asc,Posted asc" status="live" />
<txp:article_custom limit="99999" form="sitemap" sort="section asc,Posted asc" status="sticky" />
</ul>

For example, I have an About section which contains both sticky and live articles. Using the above will just show the About section twice. So it looks like this in the sitemap;

About (Live)
-Article 1
-Article 3
-Article 4

About (Sticky)
-Article 2
-Article 5

Last edited by darock (2008-12-05 23:58:18)

Offline

#4 2008-12-06 00:43:03

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: Can Article_custom display 2 statuses instead of just 1?

Try smd_query

Offline

#5 2008-12-09 21:58:33

darock
Member
Registered: 2007-11-23
Posts: 54

Re: Can Article_custom display 2 statuses instead of just 1?

bleh. that is taking me a while just to wrap my head around that sql language. any other suggestions?

Offline

#6 2008-12-09 23:08:06

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

Re: Can Article_custom display 2 statuses instead of just 1?

Place the next string where you need

<txp:article_custom limit="99999" form="sitemap_extended" sort="section asc,Posted asc" status="live" />

form sitemap_extended:

<!-- you sitemap form content form here... -->
  <li><txp:permlink><txp:title /></txp:permlink></li>
<!-- ...to here-->

<txp:if_last_article>
<txp:article_custom limit="99999" form="sitemap_original" sort="section asc,Posted asc" status="sticky" />
</txp:if_last_article>

form sitemap_original:

<!-- you sitemap form content form here... -->
  <li><txp:permlink><txp:title /></txp:permlink></li>
<!-- ...to here-->

By this firstly all live articles will pass through form sitemap_extended, than, when last live article is passing the form, the new form sitemap_original will be called for sticky articles. Not very beautiful, but should work :)


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

#7 2008-12-09 23:12:55

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Can Article_custom display 2 statuses instead of just 1?

I’ve not used smd_query but I think it’s something like this (status 4 = live, status 5 = sticky)

<txp:smd_query 
query="SELECT * 
       FROM textpattern 
       WHERE Status >= '4' 
       AND Posted < now() 
       AND ( (Section = '?s') )  
       ORDER BY Posted Desc"
form="myForm" />

You could post in the smd_query thread for more information


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#8 2008-12-09 23:16:27

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

Re: Can Article_custom display 2 statuses instead of just 1?

If you’re using 4.0.7 you can do this:

<txp:section_list sort="title asc" wraptag="ul" break="li">
	<txp:section link="1" title="1" />
	<ul>
	<txp:article_custom status="sticky" section='<txp:section />' limit="99999" form="sitemap">
		<li><a href="<txp:permlink />"><txp:title /></a></li>
	</txp:article_custom>
	<txp:article_custom section='<txp:section />' limit="99999" form="sitemap">
		<li><a href="<txp:permlink />"><txp:title /></a></li>
	</txp:article_custom>
	</ul>
</txp:section_list>

Note:

  1. This will display (and sort!) first your sticky articles, then the live articles, in one – nested – unordered list.
  2. If a section has no articles, it will still output the empty <ul></ul> tags. You can prevent this by using wraptag="ul" in the article_custom tags instead, but that will give you two unordered lists, one for the sticky articles and one for the live articles.

Edit: wow, three different solutions in less than 10 minutes :)

Last edited by els (2008-12-09 23:22:34)

Offline

Board footer

Powered by FluxBB