Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Alternate Text for Expired Article
www.WorkSmart.com – specifically the “Protection & Recovery: A Business Continuity Plan” section in the lower middle section.
On the home page, I have a form that displays an article using a custom form. However, the article posted there will occassionaly expire, and I’d like to show a different static article there when that happens.
How can I utilize the if_expires tag to show a completely different article?
I might just be thinking about this incorrectly, and any guidance would be appreciated.
Offline
Re: Alternate Text for Expired Article
maybe this would work
<txp:variable name="hasarticles" value='<txp:article_custom category="yourcategory" limit="1" />' /> - any other attributes
<txp:if_variable name="hasarticles" value="">
<txp:article_custom id="id of the alternative article" />
<txp:else />
<txp:article_custom "your attributes here" />
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Alternate Text for Expired Article
sweet – thanks. i’ll give it a shot.
Offline
Re: Alternate Text for Expired Article
worked perfectly. thank you.
Offline
#5 2009-05-04 20:55:10
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: Alternate Text for Expired Article
Hi. I have a similar request. I have a list of the upcoming events on my front page that are future articles. My article form uses the <txp:if_expired> tag to display only articles that have not expired yet. What I want to do is display a message if there are no upcoming events.
I tried to modify the code above, this is what I have that doesn’t work.
<txp:variable name="hasarticles" value='<txp:article_custom form="customevents" pgonly="1" section="events" sort="Posted asc" />' />
<txp:if_variable name="hasarticles" value="">
<txp:article_custom id="10" />
<txp:else />
<txp:article_custom form="customevents" pgonly="1" section="events" sort="Posted asc" />
</txp:if_variable>
Offline
Re: Alternate Text for Expired Article
Are you sure your form default
contains tags to display article_id=10? Because you’ve suppressed defining form in your <txp:article_custom id="10" />
, than default
form is used.
Can you post here tag-trace? (Enable debugging mode in options and post here site’s code here)
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 2009-05-04 21:59:50
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Alternate Text for Expired Article
immarabi wrote:
My article form uses the <txp:if_expired> tag to display only articles that have not expired yet.
I think in that case your variable’s value will always be empty… try using another form in the article_custom tag here: value='<txp:article_custom form="customevents" pgonly="1" section="events" sort="Posted asc" />'
Oh, and article_custom doesn’t have an attribute pgonly
.
Edit: and add time="future"
.
Last edited by els (2009-05-04 22:02:13)
Offline
#8 2009-05-05 04:03:23
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: Alternate Text for Expired Article
Thanks for the help, I am getting closer.
here are the line on my page template. The problem is that when there is an event, the event does not display. I used the form customevents to display events in a separate list, so that form is not the problem. It is only when I try to use the variable tag, that things go bananas.
<txp:variable name="hasarticles" value='<txp:article_custom form="customevents" section="events" sort="Posted asc" time="future" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<txp:article_custom id="10" form="noevents" />
</txp:if_variable>
and here is the results of the debugging
<txp:variable name="hasarticles" value='<txp:article_custom form="customevents" pgonly="1" section="events" sort="Posted asc" />' />
[attribute 'value']
<txp:article_custom form="customevents" pgonly="1" section="events" sort="Posted asc" />
[SQL (0.001417875289917): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and Section IN ('events') order by Posted asc limit 0, 10]
[article 1]
[SQL (0.00038003921508789): select Form from txp_form where name='customevents']
[Form: customevents]
<txp:if_expired>
[<txp:if_expired>: true]
</txp:if_expired>
[article 5]
[Form: customevents]
<txp:if_expired>
[<txp:if_expired>: true]
</txp:if_expired>
[/attribute]
<txp:if_variable name="hasarticles" value="">
[<txp:if_variable name="hasarticles" value="">: false]
<txp:article_custom id="10" form="noevents" />
[SQL (0.0015099048614502): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status >= 4 and Posted <= now() and ID IN (10) order by Posted desc limit 0, 10]
[article 10]
[SQL (0.00032997131347656): select Form from txp_form where name='noevents']
[Form: noevents]
<txp:body />
</txp:if_variable>
Thanks in advance for all your help.
Offline
#9 2009-05-05 06:58:14
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Alternate Text for Expired Article
I wrote:
I think in that case your variable’s value will always be empty…
Remove the form
attribute:
<txp:variable name="hasarticles" value='<txp:article_custom section="events" sort="Posted asc" time="future" />' />
Offline
#10 2009-05-06 02:42:23
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: Alternate Text for Expired Article
this is what finally worked. Thanks for helping.
<txp:variable name="hasarticles" value='<txp:article_custom section="events" time="future" />' />
<txp:if_variable name="hasarticles" value="">
<txp:article_custom id="10" form="noevents" />
<txp:else />
<txp:article_custom form="customevents" section="events" sort="Posted asc" time="future" />
</txp:if_variable>
Offline
Pages: 1