Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-11-26 21:17:00
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Turning an article on/off
I need to make a page with a dynamic section for displaying coming events.
When an event is planned, the publisher is supposed to make a box appear with info on the frontpage. When no events are coming up, the box isn’t supposed to be there.
I can’t get my head around a decent way of doing this, with out having to copy/paste HTML every time.
Offline
Re: Turning an article on/off
<txp:article_custom form="upcoming_events" section="events" sort="Posted asc" status="4" time="future" limit="5" />
This will display up to 5 future articles when the most future one is at the top.
Last edited by THE BLUE DRAGON (2009-11-26 23:18:31)
Offline
#3 2009-11-26 23:34:05
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Re: Turning an article on/off
Oh yeah! Setting the date to the (future) date of the event is a clever take on it. I’ll test it out.
Thank you! :-)
Offline
#4 2009-12-14 11:19:58
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Re: Turning an article on/off
Trouble… The article is still shown on the frontpage, after the date is expired though I set time to future
.
How do I make it disappear as soon as we hit the future date/time it’s posted on?
<txp:article_custom section="forside" form="event" limit="1" pgonly="0" searchall="0" sort="Posted asc" status="4" time="future" />
Offline
#5 2009-12-14 19:13:24
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Re: Turning an article on/off
Maybe I will have to ‘hardcode’ a solution with PHP, checking the time
attribute of the article?
Offline
Re: Turning an article on/off
If it set on ‘future’ time so it should not display anything at all when the date become as a past.
go check if you did set the ‘future’ time to any of the ‘article’ tags or if you didn’t set the ‘any’ time.
(<txp:article /> / <txp:article_custom /> / or a plugin tag that support it)
Offline
#7 2009-12-14 20:35:23
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Turning an article on/off
Gil is right, your tag shouldn’t display past artices. Can you post a tag trace of the page where this tag is?
Offline
#8 2009-12-14 22:46:34
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Re: Turning an article on/off
<!-- Runtime: 0.0220 -->
<!-- Query time: 0.011918 -->
<!-- Queries: 17 -->
<!-- Memory: 2230Kb, <txp:title /> -->
<!-- txp tag trace:
[SQL (0.0013940334320068): select name, data from txp_lang as txp_lang where lang='en-gb' AND ( event='public' OR event='common')]
[SQL (0.00028705596923828): select name, code, version from txp_plugin as txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (0.00032281875610352): select name from txp_section as txp_section where `name` like 'frontpage' limit 1]
[SQL (0.00031590461730957): select page, css from txp_section as txp_section where name = 'frontpage' limit 1]
[SQL (0.00146484375): select host from txp_log as txp_log where ip='90.184.9.68' limit 1]
[SQL (0.00041103363037109): insert into txp_log set `time`=now(),page='/frontpage',ip='255.255.255.255',host='lol.dk',refer='',status='200',method='GET']
[SQL (0.00067806243896484): select user_html from txp_page as txp_page where name='default']
[Page: default]
<txp:page_title />
[SQL (0.00028705596923828): select title from txp_section as txp_section where name='frontpage']
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:feed_link flavor="atom" format="link" label="Atom" />
<txp:feed_link flavor="rss" format="link" label="RSS" />
<txp:rsd />
<txp:site_url />
<txp:site_name />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:site_url />
<txp:if_category>
[<txp:if_category>: false]
<txp:if_article_list>
[<txp:if_article_list>: true]
<txp:image id="3" class="headpic" />
[SQL (0.00052118301391602): select * from txp_image as txp_image where id = 3 limit 1]
<txp:site_url />
<txp:article_custom id="2" form="body_only" />
[SQL (0.0011501312255859): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern as textpattern where 1=1 and Status >= 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and ID IN (2) order by Posted desc limit 0, 10]
[article 2]
[SQL (0.00025081634521484): select Form from txp_form as txp_form where name='body_only']
[Form: body_only]
<txp:body />
<txp:site_url />
<txp:article_custom id="3" form="body_only" />
[SQL (0.00093388557434082): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern as textpattern where 1=1 and Status >= 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and ID IN (3) order by Posted desc limit 0, 10]
[article 3]
[Form: body_only]
<txp:body />
<txp:site_url />
<txp:article_custom section="frontpage" form="event" limit="1" pgonly="0" searchall="0" sort="Posted asc" status="4" time="future" />
[SQL (0.0010800361633301): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern as textpattern where 1=1 and Status = 4 and Posted > now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('frontpage') order by Posted asc limit 0, 1]
[article 31]
[SQL (0.00024104118347168): select Form from txp_form as txp_form where name='event']
[Form: event]
<txp:title />
<txp:if_excerpt>
[<txp:if_excerpt>: false]
</txp:if_excerpt>
<txp:body />
<txp:site_url />
<txp:article_custom form="blog_excerpt" limit="3" pgonly="0" section="blog" sort="Posted desc" />
[SQL (0.0016829967498779): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern as textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('blog') order by Posted desc limit 0, 3]
[article 36]
[SQL (0.00025296211242676): select Form from txp_form as txp_form where name='blog_excerpt']
[Form: blog_excerpt]
<txp:permlink>
<txp:title />
</txp:permlink>
<txp:excerpt />
<txp:permlink />
<txp:title />
[article 35]
[Form: blog_excerpt]
<txp:permlink>
<txp:title />
</txp:permlink>
<txp:excerpt />
<txp:permlink />
<txp:title />
[article 34]
[Form: blog_excerpt]
<txp:permlink>
<txp:title />
</txp:permlink>
<txp:excerpt />
<txp:permlink />
<txp:title />
</txp:if_article_list>
</txp:if_category>
[ ~~~ secondpass ~~~ ]
-->
Offline
#9 2009-12-14 23:46:31
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Turning an article on/off
and Posted > now()
The tag should definitely display only future articles.
Are you absolutely sure the ‘posted’ date of your article #31 is not in the future? If it isn’t, are your time zone and DST settings in Preferences correct? Check if the ‘Date format’ options in Basic preferences show your exact local time.
Offline
#10 2009-12-15 00:02:03
- korpulente
- Member
- Registered: 2009-01-29
- Posts: 36
Re: Turning an article on/off
Further testing shows me that there seems to be some delay, between when an article is posted and when it is shown on the site. This is weird in itself, but maybe the same delay applies when an article is being pulled off the site. Before I just waited about two minutes after the given time, and concluded that it didn’t work.
I will check this out. Need to be patient(?).
Last edited by korpulente (2009-12-15 00:02:57)
Offline
#11 2009-12-15 00:12:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Turning an article on/off
Does clearing the browser cache make a difference?
Offline
Pages: 1